I am quite new to GWT and going to develop the UI for user-management application using GWT.
I am planning to use existing module which created using Spring/Hibernate. I figured out how to integrate GWT with Spring but I am not sure how to design the layout.
I want two pages:
User registration page (want to embedd GWT widget in HTML)
Administration page (seperate HTML as above with GWT widget embedded)
I am planing to use Spring Security,shall I use simple JSP login page or can I use RIA GWT login widget?
What can I use for above requirements? multiple GWT modules?
You could make 2 modules, one for the login widget, and another for the admin widget. Each widget will insert itself into a div in whichever html (or jsp) page you want.
For example, create a *.gwt.xml for each module, for example: login.gwt.xml and admin.gwt.xml. These files should both be created at the root of your gwt package, for example: com.gwt.example.
Next, create an "Entry Point" class for each (each class will implement EntryPoint). For example, Login.java might look like:
package com.gwt.example.myproject.client;
public class Login implements EntryPoint {
public void onModuleLoad() {
... create loginWidget ..
RootPanel.get("my-login-div").add(loginWidget);
}
}
So, now, when you do a gwt compile, it should create a bunch of files under war/com.gwt.example. The two you're interested in are com.gwt.example.login.nocache.js and com.gwt.example.admin.nocache.js.
Now, you can add these two js scripts into any html and/or jsp page as needed.
To complete the example, you could add the following html to add the login widget:
<html>
....other stuff...
<script type="text/javascript" language="javascript" src="com.gwt.example.login.nocache.js"></script>
....other stuff....
<div id="my-login-widget"></div>
....the rest of your html markup....
</html>
So, when you browse to this html page, it loads compiled gwt javascript, which knows to load onModuleLoad, which looks for div with id="my-login-widget" and inserts the login widget.
I've never used Spring Security, so can't be much help, other than this article looks like it might describe how to make Spring Security work over ajax.
You can create two modules or use only one.
I recently created an application where there was only one page, and the login panel was shown first, like an inner dialog box. When the session expired, the user was prompted to enter his credentials again. But I was going for a 100% no-page-refresh approach. It is nice, but the disadvantage is that the browser will have to download everything upfront. Well… at least until GWT 2.0.
Related
I have created a minimal web app with maven following the tutorial
I want to add my own Java components into the webapp. I found these guides: guide1 and guide2
But I still cannot make a page in Pages App using templates from links above (just do not have that templates)
What am I doing wrong? Should I try smth else? Thanks.
There are 2 types of templates that Magnolia supports if you want to use it to render content as well as supply it. There is a page template that is associated with over page and then there is a component template that is used to render components within the page. Each page can have only one page template associated with them while it can contain multiple components of different type and multiple instances of those components as well.
From what I can see, your first guide will only create structure for templates in the generated module, but not actual templates. And your second guide will only create templating function and component template to demonstrate that function, but not a page template.
So first, you should check that in your module structure, somewhere under /src/main/resources/<your module name>/templates you have subfolder called pages and in that folder you have defined page template. And second, you might want to follow this guide for creating and registering page template.
Or if you want to skip java module altogether and do it just as a light module you can follow the guide here.
I am attempting to learn Java EE. After struggling through trying to understand the Java stack, it appears that that a basic dynamic web application can be accomplished by focusing on JSP and Servlets so I want to start there.
In Net Beans I have a basic project set up with a tomcat server and when I hit run I can get the web page to generate and display the default index.jsp page. I have added a css file to the project and this jsp page looks like any standard html page now. I then create a new servlet. I was also able to create a link in the index.jsp page so when I click on it, it calls the servlet.
What I don't understand is why when I create the servlet in Net Beans, the processRequest method comes pre-populated with several html print statements. I could easily make this page look like the jsp page I started with, making me wonder why I even need a JSP page. It appears the entire application could be comprised of servlets.
Could someone please explain the proper interaction between the two? It appears the index page can contain links that call various servlets, perhaps to access a database of comments, then do I create the response table in the servlet, or would I pass that information to another JSP page?
Understanding these basic workflows would really help. Thanks
JSP also a kind of a servlet . Right after you run the jsp , go to your netbeans project directory and right click the jsp and select view Servlet then you get the servlet representation of your jsp file. Actually jsp file is there to perform front end design easily. Without jsp It is really difficult task to perform front-end developing stuff inside servlet.
And you should keep in mind there is no such a thing called proccessRequest in javaEE . It is automatically generated by Netbeans once you create a new servlet. So just stick to basics. Erase all the auto-generated stuff from the class which has extended HttpServlet. And then you can override the required HTTP method/methods. (doGet , doPost etc..) You should take a look at this for more infromation ...
And this page will also improve your knowledge on javaEE
Q1: Does Spring or any opensource java UI framework support partial views like that in asp.net mvc?
For example in my main index.html (or _layout.cshtm per asp.net mvc3 spec)
I would have the folllowing code:
<span id="logindisplay">#Html.Partial("_LogOnPartial")</span>
where #Html is a helper to display a partial view for _LogonPartial.cshtml which just injected it's html view contents into the page?
Q2: If this is supposed If I want to display a bunch of partial views it would be helpful to display them concurrently in parallel to improve performance. Very similar to what linkedin is doing using dust and fizzy? http://engineering.linkedin.com/profile/engineering-new-linkedin-profile
Q3: Is fizzy available as open source like that of dust?
If you want to include content of a page into another page, by adding some code on the page itself, you should compare asp with jsp, not ASP.NET MVC* with JEE - Spring MVC
So, an equivalent to <span id="logindisplay">#Html.Partial("_LogOnPartial")</span> on a jsp would be one / all of the following
On your jsp, include content from another jsp using <%# include file="../includes/inner-content.jsp" %>. This is what is called a static include. The source of the included jsp is included and made part of the parent jsp, before the jsp is compiled. If you use an IDE, it will check to ensure the included jsp does infact exist at the path specified, relative to the location of the jsp in which you are adding the include. Technically this is a JSP Directive. The jsp being included could just be a fragment, and not addressable from the outside world (could be hidden inside WEB-INF)
You can also use what's called a Dynamic include <jsp:include page="someJSP.jsp" />. In this case, the included JSP should be addressable from the browser and should be capable of being rendered independently. When the server is executing the servlet to render the parent JSP, it stops when this tag is seen, and starts executing the servlet for the included jsp, the output obtained from the inner jsp execution is then merged to the output of the parent jsp, and processing of the parent jsp is resumed.
A third option would be to use Core JSTL taglib's <c:import url=""/>. This works just like option 2 above, except it also allows you to import a page / content from a url that lives outside your application. Basically you can mention a path to a jsp, or relative URI to a servlet mapping in your application, or a URL to an external page.
Now, I suspect this is not really what you want to do, if you are comparing with what Linkedin is doing. You want to mashup content from sources in your own application, and compose your page. You also want to do this in an asynch manner so as to keep load times in check. In this case, you HAVE to use JavaScript and Ajax. All the mechanisms described above are for server rendered pages (All HTML is created before the page is rendered in the browser). Just like #HTML. You need to create a simple framework / use an existing one, where once a page loads, it fires asynch ajax calls to the server to get content for specific areas on the page and renders the returned HTML in those specific areas.
Hope this helps.
Do let me know if I've misunderstood your question.
I personally do not have much experience working in jsp and struts2 tomcat server but I have a small task that I have to deal with a server in production. I looked at info on the internet for two nights but seems like i can't get the answer.
What I want to do is to open some static simple html pages pop-up from the jsp pages that already exist. Those jsp pages are currently located at /webapps/WEB-INF/tld/mainPage/indexMainPage.jsp
what I did was:
make some javascript functions so that when they click a button, i open a pop-up
function btn_openPopUp()
{
window.open("../popUp/test.html");
}
and put the test.html page at /webapps/WEB-INF/tld/popUp/test.html
The pop-up part works fine as it is just simplye javascript, but test.html is not displayed.
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
There is no Action mapped for namespace / and action name test.
I have been looking at info online, and everything about struts is action based. Is there anyway I can open a page like on a regular server?
Pages under WEB-INF are not directly accessible to clients; put such pages under the root somewhere.
They can still be in sub-directories if it makes sense, just not under WEB-INF. If they must be under WEB-INF for some reason (which makes no sense for non-JSP pages) they can be streamed through an action like any other file--bit that'd be weird for HTML pages.
Actually, for my project I have two predefined HTML files (one for login and one for the application).
I have to use GWT and until now, the application(with its html file) and the login page are working well.
However I need to assemble the two modules, and I am wondering how can I make call from one html file to another with gwt? and should I define two different UIbinders, or I have to put everything in only one (if it is the last solution, how can I do it?)
Thanks.
If you need this all in one application, then you should have one html host page and two UiBinder files. One for main app page and one for login. You can programmatically show the login "page" when required.
You might want to read how to mage "pages" within GWT app: gwt multi-page application
Just create one html file and one module. In the html file, have two divs, such as:
<div id="login"/>
<div id="application"/>
In the module, import the Java classes that you had used for the application and the login screen. And then in your module's onModuleLoad() create the login and application panels, and add them like this:
RootPanel.get("login").add(loginPanel);
RootPanel.get("application").add(applicationPanel);
They should work just fine together. HTH.