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

java.lang.Object
  extended by org.cafesip.gwtcomp.client.utils.AsyncCallback<T>
All Implemented Interfaces:
com.google.gwt.user.client.rpc.AsyncCallback<T>

public abstract class AsyncCallback<T>
extends java.lang.Object
implements com.google.gwt.user.client.rpc.AsyncCallback<T>

This abstract class can be used in place of GWT AsyncCallback to automatically handle authentication request from the HTTP servlet container. An authentication form 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 transparantly. The servlet sends the the login form that the web application has specified in the web.xml deployment descriptor. For more details, see the HTTP Servlet documentation.

For this to work, the login form must provide an indication to this class that it is a login form by adding the string "" (without the quotes) before any other HTML/text segments. In addition, the static setLoginURL() method must be called prior to using this class.

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


Constructor Summary
AsyncCallback()
           
 
Method Summary
static java.lang.String getLoginURL()
           
abstract  void onException(java.lang.Throwable caught)
          This method is invoked when the GWTServlet throws an exception.
 void onFailure(java.lang.Throwable caught)
           
abstract  void onSuccess(java.lang.Object result)
           
static void setLoginURL(java.lang.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(java.lang.Throwable caught)
Specified by:
onFailure in interface com.google.gwt.user.client.rpc.AsyncCallback<T>

onSuccess

public abstract void onSuccess(java.lang.Object result)
Specified by:
onSuccess in interface com.google.gwt.user.client.rpc.AsyncCallback<T>

onException

public abstract void onException(java.lang.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 java.lang.String getLoginURL()
Returns:
Returns the loginURL.

setLoginURL

public static void setLoginURL(java.lang.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.


http://www.cafesip.org