GWT: problem with application architecture

I have few problems developing a GWT application. I am trying to develop an RIA application (with only one main widget, giving it a call to Main). First, the user must be registered. Here is my way to do this, but it has a problem, you will see.

  • Show root panel login components.
  • If the login was successful (checks the database), show the main widget
  • A widget has been added to the root panel

Everything works, but when you click Refresh , it again displays the input components ... All this happens in the method onModuleLoad.

How do I redo this logic? I would like the user to register (this means that the RootPanel will store the main widget) for a certain amount of time.

+3
source share
2 answers

http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ

How to remember logins

Our login system still misses a useful function: Now it requires users to log in again each time.

We can use cookies to allow a web browser to “remember” the login. In GWT, to set a cookie (which you do immediately after receiving the GWT code, the answer, as we did in the previous code snippet):

String sessionID = /*(Get sessionID from server response to your login request.)*/;
final long DURATION = 1000 * 60 * 60 * 24 * 14; //duration remembering login. 2 weeks in this example.
Date expires = new Date(System.currentTimeMillis() + DURATION);
Cookies.setCookie("sid", sessionID, expires, null, "/", false);

Now you can run the following code right after yours! EntryPoint begins execution:

String sessionID = Cookies.getCookie("sid");
if ( sessionID != null ) checkWithServerIfSessionIdIsStillLegal();
else displayLoginBox();

Remember - you should never rely on the sessionID sent to your server in the cookie header; look only at sessionID that your GWT application is explicitly sent to the message payload on your server.

, GWT , , :

http://code.google.com/webtoolkit/doc/latest/tutorial/appengine.html#user

Google App Engine , , , , GWT RPC .

+3

.

, , . onModuleLoad() , , , .

, Refresh, .

+1

Source: https://habr.com/ru/post/1788326/


All Articles