Package com.google.gwt.jsonp.client
Class JsonpRequest<T>
- java.lang.Object
-
- com.google.gwt.jsonp.client.JsonpRequest<T>
-
- Type Parameters:
T
- the type of the response object.
public class JsonpRequest<T> extends java.lang.Object
A JSONP request that is waiting for a response. The request can be canceled.
-
-
Constructor Summary
Constructors Constructor Description JsonpRequest(AsyncCallback<T> callback, int timeout, boolean expectInteger, java.lang.String callbackParam, java.lang.String failureCallbackParam)
Create a new JSONP request.JsonpRequest(AsyncCallback<T> callback, int timeout, boolean expectInteger, java.lang.String callbackParam, java.lang.String failureCallbackParam, java.lang.String id)
Create a new JSONP request with a hardcoded id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels a pending request.AsyncCallback<T>
getCallback()
(package private) java.lang.String
getCallbackId()
int
getTimeout()
(package private) void
send(java.lang.String baseUri)
Sends a request using the JSONP mechanism.java.lang.String
toString()
-
-
-
Constructor Detail
-
JsonpRequest
JsonpRequest(AsyncCallback<T> callback, int timeout, boolean expectInteger, java.lang.String callbackParam, java.lang.String failureCallbackParam)
Create a new JSONP request.- Parameters:
callback
- The callback instance to notify when the response comes backtimeout
- Time in ms after which aTimeoutException
will be thrownexpectInteger
- Should be true if T isInteger
, false otherwisecallbackParam
- Name of the url param of the callback function namefailureCallbackParam
- Name of the url param containing the failure callback function name, or null for no failure callback
-
JsonpRequest
JsonpRequest(AsyncCallback<T> callback, int timeout, boolean expectInteger, java.lang.String callbackParam, java.lang.String failureCallbackParam, java.lang.String id)
Create a new JSONP request with a hardcoded id. This could be used to manually control which resources are considered duplicates (by giving them identical ids). Could also be used if the callback name needs to be completely user controlled (since the id is part of the callback name).- Parameters:
callback
- The callback instance to notify when the response comes backtimeout
- Time in ms after which aTimeoutException
will be thrownexpectInteger
- Should be true if T isInteger
, false otherwisecallbackParam
- Name of the url param of the callback function namefailureCallbackParam
- Name of the url param containing the failure callback function name, or null for no failure callbackid
- unique id for the resource that is being fetched
-
-
Method Detail
-
cancel
public void cancel()
Cancels a pending request. Note that if you are using preset ID's, this will not work, since there is no way of knowing if there are other requests pending (or have already returned) for the same data.
-
getCallback
public AsyncCallback<T> getCallback()
-
getTimeout
public int getTimeout()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getCallbackId
java.lang.String getCallbackId()
-
send
void send(java.lang.String baseUri)
Sends a request using the JSONP mechanism.- Parameters:
baseUri
- To be sent to the server.
-
-