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
On 27 April 2010 12:38, StrongSteve <[email protected]> wrote:
> 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 <[email protected]> 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.
> >
> > On Apr 26, 8:25 am,StrongSteve<[email protected]> wrote:
> >
> >
> >
> > > 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 [email protected]
> .
> > To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.