Session Timeout Popup

613 views
Skip to first unread message

StrongSteve

unread,
Apr 26, 2010, 10:25:42 AM4/26/10
to Google Web Toolkit
Hi Everbody,

I am looking for a way to implement a session timeout behaviour into
my GWT application.

On the ServerSide I have a session listener that sets the value for
the session timeout as soon as a new session is being created.

Now what I would like to do is to present the user a popup as soon as
the session has experied.
This does not have to happen automatically. It is also ok to show this
popup as soon as a new request is addressed against the server.

Now I am looking for some best practices on how to deal with this
problem.
I believe some of you have already dealt with similar problem! ;)

Thanks in Advance for your help!

Greetings
Stefan

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

kozura

unread,
Apr 26, 2010, 11:08:09 AM4/26/10
to Google Web Toolkit
Easiest is probably to just create an exception for session timeout,
and throw it on the server side after you check for session validity.
Then put a standard method in your onFailure call to popup the error
when that exception is received.

StrongSteve

unread,
Apr 27, 2010, 3:08:10 AM4/27/10
to Google Web Toolkit
Thanks for your quick reply.

I am just wondering if there is no easier way to do this.

I mean, adding an exception to all server methods and checking it in
every onFailure block does not seem so pratical to me.

There should be an easier way!

Thanks in Advance!
Stefan

On Apr 26, 5:08 pm, kozura <koz...@gmail.com> wrote:
> Easiest is probably to just create an exception for session timeout,
> and throw it on the server side after you check for session validity.
> Then put a standard method in your onFailure call to popup the error
> when that exception is received.
>

Sripathi Krishnan

unread,
Apr 27, 2010, 5:29:55 AM4/27/10
to google-we...@googlegroups.com
Just have a custom class the extends AsyncCallback, like below, and mandate that everybody uses it instead of directly using AsyncCallback.

public abstract class MyAsyncCallback<T> implements AsyncCallback<T> {
 
      public void onFailure(Throwable caught) {
              if(caught instanceof AuthenticationException) {
                    //redirect to login page
              }
              else if(caught instanceof AuthorizationException) {
                    //tell the user he doesn't have rights to perform this operation
              }
             
              try {
                      //allow your application to handle the exception
                      handleFailure(caught);
              }
              catch(Throwable e) {
                     //default application-wide error handling
              }
      }

      //provide a default implementation. Code that wants to handle exceptions can do so by overriding this method
      //Lazy developers can just ignore it, and the app-wide error handling framework will do the needful
      public void handleFailure(Throwable t) throws Exception {
             throw t;
      }
}


--Sri

nacho

unread,
Apr 27, 2010, 1:02:04 PM4/27/10
to Google Web Toolkit
How do redirect to another page in GWT?

On 27 abr, 06:29, Sripathi Krishnan <sripathikrish...@gmail.com>
wrote:
> Just have a custom class the extends AsyncCallback, like below, and mandate
> that everybody uses it instead of directly using AsyncCallback.
>
> public abstract class MyAsyncCallback<T> implements AsyncCallback<T> {
>
>       public void onFailure(Throwable caught) {
>               if(caught instanceof AuthenticationException) {
>                     //redirect to login page
>               }
>               else if(caught instanceof AuthorizationException) {
>                     //tell the user he doesn't have rights to perform this
> operation
>               }
>
>               try {
>                       //allow your application to handle the exception
>                       handleFailure(caught);
>               }
>               catch(Throwable e) {
>                      //default application-wide error handling
>               }
>       }
>
>       //provide a default implementation. Code that wants to handle
> exceptions can do so by overriding this method
>       //Lazy developers can just ignore it, and the app-wide error handling
> framework will do the needful
>       public void handleFailure(Throwable t) throws Exception {
>              throw t;
>       }
>
> }
>
> --Sri
>
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

charlie

unread,
Apr 27, 2010, 1:16:46 PM4/27/10
to google-we...@googlegroups.com
Gah, wish I would have done this at the start instead of at the end.  Good call though.
--
<charlie/>

gcstang

unread,
Apr 27, 2010, 1:29:03 PM4/27/10
to Google Web Toolkit
Nice idea but what about when the data is all client side that they
are dealing with...until they try to hit the server it still won't
show a popup.

Any other ideas?

The only other thing I can think of combined with yours is have a call
made every min or less in a timer that makes a call using your method?

Of course this would have to be in something that doesn't leave the
screen like in a header or footer I would guess.


On Apr 27, 4:29 am, Sripathi Krishnan <sripathikrish...@gmail.com>
wrote:
> Just have a custom class the extends AsyncCallback, like below, and mandate
> that everybody uses it instead of directly using AsyncCallback.
>
> public abstract class MyAsyncCallback<T> implements AsyncCallback<T> {
>
>       public void onFailure(Throwable caught) {
>               if(caught instanceof AuthenticationException) {
>                     //redirect to login page
>               }
>               else if(caught instanceof AuthorizationException) {
>                     //tell the user he doesn't have rights to perform this
> operation
>               }
>
>               try {
>                       //allow your application to handle the exception
>                       handleFailure(caught);
>               }
>               catch(Throwable e) {
>                      //default application-wide error handling
>               }
>       }
>
>       //provide a default implementation. Code that wants to handle
> exceptions can do so by overriding this method
>       //Lazy developers can just ignore it, and the app-wide error handling
> framework will do the needful
>       public void handleFailure(Throwable t) throws Exception {
>              throw t;
>       }
>
> }
>
> --Sri
>
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
> > .

Sripathi Krishnan

unread,
Apr 27, 2010, 1:47:15 PM4/27/10
to google-we...@googlegroups.com
Nice idea but what about when the data is all client side that they
are dealing with...until they try to hit the server it still won't
show a popup.

Can't do much about it, and there is no point in thinking about it as well. I don't know any website that does anything about it. Besides, its only a matter of minutes before the app is going to make a server call.


The only other thing I can think of combined with yours is have a call
made every min or less in a timer that makes a call using your method?
Sure, it would work. Its just too much effort for a feature that's not all that worth (atleast imho). Besides, it has the disadvantage (or advantage?) of never timing out your session, and also being a n/w hog.

--Sri
Reply all
Reply to author
Forward
0 new messages