Gwt-Ext “Login” example
Jun 29th, 2008 by Dariusz
After my post of how to setup a proper Gwt-Ext application in Eclipse, I would like to show how to develop a simple “Login” application using CypalStudio plugin.
Instead of showing a basic HelloWorld, I would like to do a more realistic example. I decided to do a Login functionality, but If you are interested in a simple HelloWorld, here is good example.
Allright…
First, we click on our project with the right mouse and select New->Other->Cypal Studio->Module
Now, type in your package name and the Module name, which will be your entry point in the application.
Now Cypal plugin does everything for you and you should have something similar as this:
As you can see, a structure of your application has been changed and some other files has been created automatically.
Now, it’s time to clean it up a little bit. It’s up to you, but I prefer to have it as simple as possible.
Lets open the Login.html and copy the following html code in:
-
<html>
-
<head>
-
<title>Wrapper HTML for Login</title>
-
<script language=‘javascript’ src=‘org.mypackage.Login.nocache.js’></script>
-
</head>
-
-
<body>
-
<!– OPTIONAL: include this if you want history support –>
-
<iframe src="javascript:”" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
-
-
<div id="login_widget"></div>
-
-
</body>
-
</html>
The only thing what is needed to present the widget, you are going to develop in java, is the div tag. Of course, if you want to do it a little bit more complex, you can structure your page with more than one widget.
The first step is (almost) done. To see the result, you need to do the following. Go to Run->Open Run Dialog and then click with the right mouse on “GWT Hosted Mode Application” and then on New.
It’s required to set some Java VM Option to be able to run the application.
And underneath the Run dialog you should be able to run the app.
So far, we can’t see a lot. Now it’s time to create the widget. Therefore lets open the Login.java and write some modules.
Before we do that, we need to modify our Login.gwt.xml to be able to use the ExtJS functionlities.
-
<module>
-
-
<!– Inherit the core Web Toolkit stuff. –>
-
<inherits name=‘com.google.gwt.user.User’/>
-
<!– Inherit the GWTExt Toolkit library configuration. –>
-
<inherits name=‘com.gwtext.GwtExt’ />
-
-
<!– Specify the app entry point class. –>
-
<entry-point class=‘org.mypackage.client.Login’/>
-
-
<stylesheet src="js/ext/resources/css/ext-all.css" />
-
<script src="js/ext/adapter/ext/ext-base.js" />
-
<script src="js/ext/ext-all.js" />
-
-
</module>
Now, we need to copy the files mentioned above from your Gwt-Ext folder to src/org/mypackage/public so we can use them.
The following structure should be similar to yours:
Now, lets go back to the Login.java file and copy this simple example into it and you should be able to see the first output, but without any functionality yet.
-
package org.mypackage.client;
-
-
import com.google.gwt.core.client.EntryPoint;
-
import com.google.gwt.user.client.ui.RootPanel;
-
import com.gwtext.client.widgets.Button;
-
import com.gwtext.client.widgets.Panel;
-
import com.gwtext.client.widgets.form.FormPanel;
-
import com.gwtext.client.widgets.form.TextField;
-
-
public class Login implements EntryPoint {
-
private FormPanel formPanel = new FormPanel();
-
-
public void onModuleLoad() {
-
formPanel.setFrame(true);
-
formPanel.setTitle( "Simple Login Form" );
-
formPanel.setWidth(350);
-
formPanel.setLabelWidth(75);
-
-
fName.setAllowBlank( false );
-
fName.focus();
-
formPanel.add( fName );
-
-
passWord.setInputType( "password" );
-
formPanel.add( passWord );
-
-
formPanel.addButton( loginButton );
-
-
loginPanel.setBorder( false );
-
loginPanel.setPaddings( 5 );
-
-
loginPanel.add( formPanel );
-
-
RootPanel.get("login_widget").add( loginPanel );
-
}
-
}
Run the application…
Since the Graphical User Interface is now up and running, lets implement some service into the application.

Now select “Remote Service” and click next.
Here, it’s required to choose a name for the service and define the mapping name, which will be included in our web.xml and the Login.gwt.xml automatic.
Once clicked on finish, you can see that some more classes has been created in our application.
And here are the changes made in my web.xml
-
<web-app id="WebApp_ID">
-
<display-name>MyGWTApplication</display-name>
-
<servlet>
-
<servlet-name>LoginService</servlet-name>
-
<servlet-class>
-
org.mypackage.server.LoginServiceImpl</servlet-class>
-
</servlet>
-
<servlet-mapping>
-
<servlet-name>LoginService</servlet-name>
-
<url-pattern>/login</url-pattern>
-
</servlet-mapping>
-
<welcome-file-list>
-
<welcome-file>index.html</welcome-file>
-
<welcome-file>index.htm</welcome-file>
-
<welcome-file>index.jsp</welcome-file>
-
<welcome-file>default.html</welcome-file>
-
<welcome-file>default.htm</welcome-file>
-
<welcome-file>default.jsp</welcome-file>
-
</welcome-file-list>
-
</web-app>
And the same changes for the Login.gwt.xml
-
<servlet class=‘org.mypackage.server.LoginServiceImpl’ path=‘/login’/>
-
</module>
Now, lets open Login.java and implement some logic in. As you can see in the code, I made some changes to have a better overview.
-
package org.mypackage.client;
-
-
import java.util.HashMap;
-
import java.util.Map;
-
-
import com.google.gwt.core.client.EntryPoint;
-
import com.google.gwt.core.client.GWT;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
import com.google.gwt.user.client.ui.RootPanel;
-
import com.gwtext.client.core.EventObject;
-
import com.gwtext.client.widgets.Button;
-
import com.gwtext.client.widgets.MessageBox;
-
import com.gwtext.client.widgets.Panel;
-
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-
import com.gwtext.client.widgets.form.Form;
-
import com.gwtext.client.widgets.form.FormPanel;
-
import com.gwtext.client.widgets.form.TextField;
-
-
public class Login implements EntryPoint {
-
private FormPanel formPanel = new FormPanel();
-
-
public void onModuleLoad() {
-
// call the async login service
-
final LoginServiceAsync loginService = ( LoginServiceAsync )GWT
-
.create( LoginService.class );
-
-
ServiceDefTarget endpoint = ( ServiceDefTarget )loginService;
-
endpoint.setServiceEntryPoint( moduleRelativeURL );
-
-
this.setLoginPanel();
-
-
final AsyncCallback callback = new AsyncCallback()
-
{
-
// take the result coming from the server
-
if( ok )
-
{
-
MessageBox.alert( "Success", "Successfully logged in!");
-
}
-
else
-
{
-
MessageBox.alert( "Invalid", "Wrong username or password");
-
}
-
}
-
-
MessageBox.alert( "Error", "Error while logging in" );
-
}
-
};
-
-
loginButton.addListener( new ButtonListenerAdapter() {
-
-
loginService.userIsValid( loginData, callback );
-
}
-
});
-
-
formPanel.addButton( loginButton );
-
-
loginPanel.setBorder( false );
-
loginPanel.setPaddings( 5 );
-
loginPanel.add( formPanel );
-
-
RootPanel.get("login_widget").add( loginPanel );
-
}
-
-
// setup login panel
-
private void setLoginPanel()
-
{
-
formPanel.setFrame(true);
-
formPanel.setTitle( "Simple Login Form" );
-
formPanel.setWidth(350);
-
formPanel.setLabelWidth(75);
-
formPanel.setUrl( "save-form.php" );
-
-
fName.setAllowBlank( false );
-
fName.focus();
-
formPanel.add( fName );
-
-
passWord.setInputType( "password" );
-
formPanel.add( passWord );
-
}
-
-
// prepare data for sending to the server
-
{
-
-
-
for (int i = 0; i < nameValuePairs.length; i++) {
-
loginData.put( oneItem[0], oneItem[1] );
-
}
-
-
return loginData;
-
}
-
}
The other classes look like that:
LoginService.java
-
package org.mypackage.client;
-
-
import java.util.Map;
-
-
import com.google.gwt.core.client.GWT;
-
import com.google.gwt.user.client.rpc.RemoteService;
-
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
-
public interface LoginService extends RemoteService {
-
-
-
-
public static LoginServiceAsync getInstance() {
-
-
LoginServiceAsync instance = (LoginServiceAsync) GWT
-
.create(LoginService.class);
-
ServiceDefTarget target = (ServiceDefTarget) instance;
-
target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
-
return instance;
-
}
-
}
-
-
}
LoginServiceAsync.java
-
package org.mypackage.client;
-
-
import java.util.Map;
-
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-
-
public interface LoginServiceAsync {
-
-
-
}
LoginServiceImpl.java
-
package org.mypackage.server;
-
-
import java.util.Map;
-
-
import org.mypackage.client.LoginService;
-
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
-
public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
-
-
// Here it should be something more useful e.g. sending
-
// a request to LDAP server
-
{
-
boolean accepted = false;
-
-
if( name.equals( "guest" ) && pswd.equals( "guest" ) )
-
{
-
accepted = true;
-
}
-
-
return accepted;
-
}
-
}
The result should look like this:
If you want to start the application without calling Login.html, just rename the application to Index.html and that’s it.
I hope this helps a little bit, how to send a request to the server and retrieve some result.
I used the following sources for this example:
Dariusz















In the source code of Login.java in the function getUserData you split values on “&” and not on “&”. I guess its some problem with the blog, because the same happens in the sourcecode of LoginServiceImpl.java where you check whether userName and password is “guest”, “&” should be “&”.
Regards Matt
Matt, thanks a lot. You are right, of course it should be “&” and not ” & a m p ;”. I changed the source code but can’t guarantee if this will stay so. Either it’s an editor thing or the “code highlighter” plugin.
Thanks,
Dariusz
Fine
This is a very good job! thanks to you dude! \o/
I publish your tutorial using netbeans. Thank you bro for your great example
Great tutorial! Exactly what I was looking for!
Does it support browser auto complete?
Hmm…. good question. I would say yes. You just need to exchange the TextField with a ComboBox and it should work.
http://www.gwt-ext.com/demo/#compactComboBox
I didn’t try it out myself, but seems to work like that.
Thank you, thank you, thank you !
Thank you man. Very nice stuff! Thank you for your tutorial.
Many many Thanks from POrtugal!
hi there. I’m newbie so forgive me for such questions.
Perhaps you know how to make this dialog as it would appear as a MessageBox?
I would like to centralize it and make the whole stuff behinde not accesible.
Great tutorial! Just started with Java due to these amazing gwt and yours was the one example out of many many examples that functionally gives an example of gwt-ext.
Word, brother!
Hey Pretty cool!
Now here\’s the step I\’m missing: Whether I use GWT or GWT-EXT to implement such a login page… what do I do once he\’s logged in?…
I mean… now I want to \’forward\’ the request to my actual GWT-Ext panel. Do I need to create this login panel as a complete seperate application, and if so, how do I forward the session ID to my actual application?
Of course, I could just use another panel to host my application and do show/hide, but that would mean the user downloading the full app regardless of if he\’s logged in or not (slow and security risk as you are offloading the presentation rules)?
Hi!
It’s up to your scenario how you want to implement your login panel/form. I can not tell you what’s the best solution for it.
If you want to forward the page after a successful login, you can use JNDI. What I do is for example this:
public static native void forwardToAccountPage() /*-{return $wnd.location = '../account';
}-*/;
To save your session id, you need to do it in your Impl implemention (e.g.LoginServiceImpl). You need to extend your Impl to ‘RemoteServiceServlet’. And then you are free to use/store a session ID like this:
HttpServletRequest request = this.getThreadLocalRequest();;HttpSession httpSession = request.getSession( true );
//.... after successful login do this where user is your object you want to store
httpSession.setAttribute( "user", user )
I hope it helps a bit.
Thanks, That will possibly help
I’m still trying to figure the tie-in senario to the gwt apps. e.g. I’ve got a 6 panel GWT (looking into GWT-EXT) app. I can easily make a static HTML page for the login, and use a standard servlet or JSP at the other end to recieve the request and then in the response include the HTML for my application.
That allows me quick Static/traditional JEE->gwt. I can also see how, using your example above, I could get gwt->static/traditional JEE .
The problem that I’m facing is that from my understanding to have gwt (Login) -> gwt (myApp), I would then need 2 entry points, two module.xml, and thus 2 seperate project? Since I want to create 2 GWT apps, that implies 4 projects, two of which would only handle login?
I seem to be missing an important piece of information, or have a misconception about GWT (and EXT) app segmentation…
Oh damn, I think I got your point! I was struggling with it as well until I finally (hopefully) got it to work as I wanted.
The problem is, that you have different panels written in different modules and now you would like to combine them, right? Well, if this is the case maybe it’s time to write about it, because it was difficult for me to understand it too. To bring you on the right path, maybe you should take a look how to inherit different modules.
Thanks! I’ll definitely have a look. You’ve been a good help. I don’t feel as bad about my question as I did yesterday
Thanks Again.
Where have we declared the list of resources (/account is protected by /www is not, for example) to be protected? The web.xml does not seem to have the restriction.
Please advise.
What do you mean?
If you want to implement a protection filter, then please google for authentication frameworks for Tomcat. An authentication framework in this example is not implemented.
Sorry for that…
Quite a nice example. Gwt-ext functionalities looks great!
I’m a java and gwt newbie and I have a question/note about your example (hope I am right).
You have used a FormPanel in order to provide interoperability with already deployed php site (I suppose), but in this scenario your example lacks the submit(), making the usage of the formpanel useless.
In fact you pass all the communications thru the RPC webservice.
In this case accessing the getForm() string and splitting in order to extract user and password, introduces an overhead which could be avoided by simply using TextBox.getText() method.
Perhaps I have not got the point cause my quick-and-dirty-newbie nature but I ‘ll appreciate hints in order to understand your example deeply.
Thanks
Thanks fabtar!
I’m not using php at all. FormPanel here is only used to make the submit call. Of course, you don’t need to FormPanel, you can also use any of the available Panels and add your textbox and password box in there.
Ok,
I think I have understood now. I was confused by the 83th row which stated: ” formPanel.setUrl( “save-form.php” );”
I suppose this URL is used only in case the submit() method is call which is not the case here.
Keep doing! Great Blog
Respected Sir,
I am very Happy after running my first application with the this wonderful tutorial.
Sir I want to say your thanks for this lovely tutorial.
thank you
Ankit
Why should loginService be final ?
Thank you
Hello,
I need to add images to my Application. I am very new to GWT-Ext…
I try with it in this way -
final Image image = new Image();
image.setUrl(”D:/MORIA Desktop/logo_telekom.png”);
RootPanel.get().add(image);
But i am unable to load it…Plz some9body help me……
Hai, I’m getting following error while running the application.
java.lang.NoClassDefFoundError: com/google/gwt/dev/GWTShell
Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.GWTShell
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread “main”
How to solve this issue?
Thank you.
Aditi, sorry for the late response, but I’m quite busy these days.
Did you try to set the URL rather to an image inside your public folder? Let’s say you have a structure like this:
- public
|- images
|- logo_telekom.png
- client
- server
then you would point to your public/images folder:
final Image image = new Image( “images/logo_telekom.png” );
It should work. Let me know if it’s not working.
hey,
i got a problem while linking the servlet into the implementation class. it says
com.google.gwt.user.client.rpc.StatusCodeException: Unable to find/load mapped servlet class ‘com.wisdom.test.server.LoginSericeImpl’
Are you running it in development mode?
Anyway, how does your web.xml look like?
Great tutorial for GXT newbies. Good Job.
Look on my tutorial obout how to change default GXT themes http://touk.pl/blog/2010/08/13/how-to-change-theme-in-ext-gwt-gxt-application/
greetings from Poland
Great tutos .thx
but i have some problems .when i code the file login.java , i have some error in the import started by \"com.gwtext\" and tell me that \’The import com.gwtext cannot be resolved\’
thx
Did you import the GWT-Ext modules in your *.gwt.xml like this?
< !– Inherit the GWTExt Toolkit library configuration. –>
D.
Hi Dariusz,
I am new to GWT . I have followed the steps mentioned. After running the application I am getting the following error message
Unknown argument: -style
Google Web Toolkit 2.0.4
GWTShell [-noserver] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-bindAddress host-name-or-address] [-codeServerPort port-number | "auto"] [-out dir] [url]
Earlier the error was Execption in thread main
So I added the jar in my build path
After that i got this error
Kindly Advise
Thanks in advance
Hi Kaushik,
I really can’t help you, but are you using cypal? If so, then you should read this entry:
http://code.google.com/p/cypal-studio/issues/detail?id=134
Maybe it helps.
I tried as you told but cypal studio plugin but it is not working with Helios eclipse.
1) Folder structure is coming different with Helios.
2)Also, Run Configurator is not at all accepting the project name and all.
please help me in this.
thanks in advance.
Which version of GWT are you using? I had some problems using GWT 2.0 and Cypal.
http://code.google.com/p/cypal-studio/issues/detail?id=134
> 1) Folder structure is coming different with Helios.
> 2)Also, Run Configurator is not at all accepting the project name and all.
I need some more in detail information. How does your folder structure look like?
i am trying to apply hibernate to this examples but nothing to do, i’m getting an error :
SEVERE: [1285930843468000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method ‘public abstract boolean com.login.client.LoginService.userIsValid(java.util.Map)’ threw an unexpected exception: java.lang.NoClassDefFoundError: org/hibernate/Session
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Please can anyone help me? Thank u
It seems like your hibernate wasn’t instantiated. How does your hinbernate.cfg.xml look liike? Did you implement “java.io.Serializable” in your presistent classes?
Are you using Annotations or *.hbm.xml?
Hi Sir,
First of all thanks for this nice tutorial. But i am facing a problem while running it . I am getting null pointer exception when i run this. Please help as i need your help.Thanks in advance. Following is the stack trace
WARNING: ‘com.google.gwt.dev.GWTShell’ is deprecated and will be removed in a future release.
Use ‘com.google.gwt.dev.HostedMode’ instead.
(To disable this warning, pass -Dgwt.nowarn.legacy.tools as a JVM arg.)
Exception in thread “main” java.lang.NullPointerException
at com.google.gwt.dev.shell.tomcat.EmbeddedTomcatServer.stop(EmbeddedTomcatServer.java:90)
at com.google.gwt.dev.GWTShell.doShutDownServer(GWTShell.java:220)
at com.google.gwt.dev.HostedModeBase.shutDown(HostedModeBase.java:574)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:409)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:140)
What kind of OS are you running and which version of GWT are you using? From what I see, you are running GWT >= 1.7?
Are you using Cypal studio or the Eclipse Google Plugin?
Thanks for reply,
I am using XP, with gwt-windows-1.7.1. I am using Cypal studio plugin.
Do you have some more outputs? It’s difficult to tell…” inside your “*.gwt.xml”?
Do you have all the jar files inside your WEB-IN/lib? Do you have this line “
Help me to come out of this Problem. As i am stuck here from last three days. Not getting rid of here.
Thanks a lot!!!!!!!!!!
Oops some formatting went wrong.
Again….
This one needs to go into your *.gwt.xml
jesus….
inherits name=‘com.google.gwt.user.User’
I have included this text into my Login.gwt.xml. This is the entire content of Login.gwt.xml.
<!– –>
<!– –>
Is it possible that i can send you the entire code for review? As it is yours code you will hardly take few minutes to check it out. Please…
OK, you can send it over if you want.
<!– –>
<!– –>
Where should i upload this ? Its just 3.5 mb. Should i mail you ?
I just sent you an email.
I have sent you the project. Please check it. My libraries are:- gwtext-2.0.5 ,
gwt-windows-1.7.1(gwt-servlet.jar and gwt-user.jar). Using Eclipse Helios with Cypal studio plugin.
Waiting for your reply.
Thank u Dariusz, I resolved my problem. I just payed more attention running this application.
I have another question. After this login i want to display another page that contains the grid you have shown in the other tutorial (”loading data from database: http://www.dariusz-borowski.com/wp/?p=47“).
The login part and this grid have to be in different module (and to implement them i have to search something about how to integate 2 modules in GWT-ext), or there is not a problem if they are in the same module?
Sorry my question i am really very new in GWT-EXT (just 3 days working with it)..
thanks in advance for your help
bye
Great tutorial by the way ;-), i forgot to say this
Hi Ester,
It depends on your app. Does this grid belong more to a login procedure or is it a completely different subject.
If I were you, I would keep things separately.
Your login is an authentication module. Your grid is probably an informational page about something you want to secure.
Create a new module and make it secure by using a filter…for example.
Thnx again for the answer.
I was thinking that the communication between this 2 modules may be possible with just using a simple form with action?
thnx, Ester
Well, if you want to do that then exchange your login panel with the grid one, after your login ends in the success function.
Ok, thnx.
But I want to maintain the session and the user data after login. Can i do this with the above code have written:
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession httpSession = request.getSession( true );
//…. after successful login do this where user is your object you want to store
httpSession.setAttribute( “user”, user );
thnx again for the help, Ester
Of course, you can. Did you try it out?
Maybe it’s better to make another question.
So for the grid i need to create another module inside the current project. Then in the onsuccess function of the login entry point i have to exchange my login panel with the grid one. So i have to write the html code for the grid in the same html file of the login.(or not?)
I should write the code of the session inside this onsuccess function again. (Even when i write that code, getThreadLocalRequest() is not known as a method, myeclipse says to me to create this method).
But I don’t understand, i f I just change the only the panels actually i am in the same page. Should i be in the same page because of session issue? :S
My idea is that i just want when the user login, the login forward to another page saving the session and user data where i can implement dhe logout function too.
Sorry my long wrinting…Waiting for an answer..Thnx again, Ester
I cannot switch the login panel with the grid panel :S(after i read a lot of blogs), and i cannot take the session during login function. I just cant take the data from the database and display a simple alert(”Successfully logged in!”)…
Please i need an additional help. Can you give an answer to me?
Thnx in advance ester
Ester! I’m really willing give hints and tips, but I can not design your application. This is something you have to figure out how to do this things.
As I said, you can either exchange the panel with another one, or just forward your user to a different page.
It seems, like you first need to get your request callback fixed before you continue.
Ok, I will try to do that… Thank you…Good work to you too.
Hi Dariusz,
i am very new to GWT, so may be my question might be very immature
I already have a full-fledged GWT application running. I need to write a JUnit Test case to verify Login.
I am very confused between the usage of GWTTestCase and TestCase.
Basically, i have a LoginService that calls some external .net service to verify the usercredentials.
I have read many tutorials that say use GWTTestCase to test the GWT Widgets and TestCase to test Server functionalities.
But in my LoginServiceImpl, there are many things happening using the session values. So when i use TestCase, its not able to do anything pertaining to session.
It would be really helpful if u could guide me on this.
Highly appreciate your time…
~Geeta
HI Dariusz ,
I am new to gwt-ext , i was told to create sample using the same. Luckily i got yours sample. But am unable to run it successfully.While running your application ,its not calling to rpc as i have understood. Error: while clicking the submit button its thowing the exception and showing the message “Error Occured”.
It will be highly appreciable for the given time.
Kumar
Kumar,
How do you know that you are not executing the service (RPC)? What about web.xml? Did you put in the servlet call in it? If you are running in debug mode, make sure that you also put in the servlet call in your gwt.xml file.
Dariusz
Thanks for replying,
while executing the application its throwing exception , due to which its calling onFailure(), this causes problem to occur. As you have mentioned in the application with details , i have configured in that way only. i have cross checked the web.xml… its the same as you have mentioned …. i have tried in debug mode also. by updating the gwt.xml file …but unable to find the solution.
while browsing on google i found that onFailure() is called when there is failure of (RPC) calling.
Could you make me out of these ?
Regards
kumar
Kumar,
Of course. The method onFailure() is called when there was an error. You need to catch the error in order to know where it fails. Is it on the back end or front end. Please, make some log statements on both sites to see where it’s failing.
Can you print out the error Exception on the front end? For example like this:
public void onFailure( Throwable caught ) {
GWT.log( “error caught: “+caught.getMessage(), null );
GWT.log( “error caught: “+caught.getCause(), null );
}
What is the output?
Darsiuz,
Thanks for the support i got the output. This tutorial is really great one for the beginners.
great tutorial…
Great to hear you figured it out! Have fun!
Hi,
Can you also give a demo on how to communicate between two modules in the same application?
So after successful login if the user homepage processing is in another module then how do i navigate from thee current module to this userhomepage module?