GWT 2.1.0

com.google.gwt.requestfactory.client
Class DefaultRequestTransport

java.lang.Object
  extended by com.google.gwt.requestfactory.client.DefaultRequestTransport
All Implemented Interfaces:
RequestTransport

public class DefaultRequestTransport
extends java.lang.Object
implements RequestTransport

An implementation of RequestTransport that uses a RequestBuilder.

This implementation will send RequestEvent objects to the EventBus passed into the constructor to provide indication of transport-level activity. When an HTTP request is sent, an event with a RequestEvent.State.SENT state and a null Request will be posted. When an HTTP transport completes successfully, an event will be posted with state RequestEvent.State.RECEIVED and the Request object provided to the internal RequestCallback#onResponseReceived(). If an HTTP transport fails (e.g. due to network malfunction), an event with state RequestEvent.State.RECEIVED and a null Request will be sent. The success or failure of the HTTP transport is wholly independent from whether or not the application payload was successfully executed by the server.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.gwt.requestfactory.shared.RequestTransport
RequestTransport.TransportReceiver
 
Field Summary
static java.lang.String URL
          The default URL for a DefaultRequestTransport is GWT.getHostPageBaseURL() + "gwtRequest" which may be overridden by calling setRequestUrl(String).
 
Constructor Summary
DefaultRequestTransport(EventBus eventBus)
          Construct a DefaultRequestTransport.
 
Method Summary
protected  void configureRequestBuilder(RequestBuilder builder)
          Override to change the headers sent in the HTTP request.
protected  RequestBuilder createRequestBuilder()
          Constructs a RequestBuilder using the RequestBuilder.POST method sent to the URL returned from getRequestUrl().
protected  RequestCallback createRequestCallback(RequestTransport.TransportReceiver receiver)
          Creates a RequestCallback that maps the HTTP response onto the TransportReceiver interface.
 java.lang.String getRequestUrl()
          Returns the current URL used by this transport.
 void send(java.lang.String payload, RequestTransport.TransportReceiver receiver)
          Called by the RequestFactory implementation.
 void setRequestUrl(java.lang.String url)
          Override the default URL used by this transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL

public static final java.lang.String URL
The default URL for a DefaultRequestTransport is GWT.getHostPageBaseURL() + "gwtRequest" which may be overridden by calling setRequestUrl(String).

See Also:
Constant Field Values
Constructor Detail

DefaultRequestTransport

public DefaultRequestTransport(EventBus eventBus)
Construct a DefaultRequestTransport.

Parameters:
eventBus - the same EventBus passed into RequestFactory.initialize.
Method Detail

getRequestUrl

public java.lang.String getRequestUrl()
Returns the current URL used by this transport.


send

public void send(java.lang.String payload,
                 RequestTransport.TransportReceiver receiver)
Description copied from interface: RequestTransport
Called by the RequestFactory implementation.

Specified by:
send in interface RequestTransport

setRequestUrl

public void setRequestUrl(java.lang.String url)
Override the default URL used by this transport.


configureRequestBuilder

protected void configureRequestBuilder(RequestBuilder builder)
Override to change the headers sent in the HTTP request.


createRequestBuilder

protected RequestBuilder createRequestBuilder()
Constructs a RequestBuilder using the RequestBuilder.POST method sent to the URL returned from getRequestUrl().


createRequestCallback

protected RequestCallback createRequestCallback(RequestTransport.TransportReceiver receiver)
Creates a RequestCallback that maps the HTTP response onto the TransportReceiver interface.


GWT 2.1.0