org.cafesip.gwtcomp.client.utils
Class AsyncCallback<T>

java.lang.Object
  extended by org.cafesip.gwtcomp.client.utils.AsyncCallback<T>
All Implemented Interfaces:
AsyncCallback<T>

public abstract class AsyncCallback<T>
extends Object
implements AsyncCallback<T>

This abstract class can be used in place of GWT AsyncCallback to automatically handle server communication failure including authentication request from the server. An authentication request is sent by the servlet container to the browser in response to a HTTP request when the HTTP session has timed out because of inactivity and the URL being accessed has an authentication constraint. An RPC call is a HTTP request and therefore, is given the same treatment. GWT does not handle this very well. The RPC call fails with an exception and the application has to handle this. This class takes care of the problem by handling the exception transparently. When an RPC invocation fails, GWT throws an InvocationException. This class assumes that there is a either a session timeout or the server is down. This class displays an alert message and redirects to the login page.

For this to work, the static setLoginURL() method must be called prior to using this class to set the login page.

The abstract methods are invoked when the RPC response is received from the server.

Author:
Amit Chatterjee

Constructor Summary
AsyncCallback()
           
 
Method Summary
static String getLoginURL()
           
abstract  void onException(Throwable caught)
          This method is invoked when the GWTServlet throws an exception.
 void onFailure(Throwable caught)
           
abstract  void onSuccess(T result)
           
static void setLoginURL(String loginURL)
          Set the login URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncCallback

public AsyncCallback()
Method Detail

onFailure

public final void onFailure(Throwable caught)
Specified by:
onFailure in interface AsyncCallback<T>

onSuccess

public abstract void onSuccess(T result)
Specified by:
onSuccess in interface AsyncCallback<T>

onException

public abstract void onException(Throwable caught)
This method is invoked when the GWTServlet throws an exception. Note that InvocationException thrown because of session-timeouts are automatically handled.

Parameters:
caught -

getLoginURL

public static String getLoginURL()
Returns:
Returns the loginURL.

setLoginURL

public static void setLoginURL(String loginURL)
Set the login URL. When the login form is received in response to a RPC request, this object redirects it to the page. Typically the page is set to GWT.getModuleBaseURL() + "appname.html" where the appname.html is the starter HTML for the GWT application.

Parameters:
loginURL - The loginURL to set.


Copyright © 2010 Cafesip.org. All Rights Reserved.