com.smartgwt.client.rpc
Class RPCManager

java.lang.Object
  extended by com.smartgwt.client.rpc.RPCManager

public class RPCManager
extends Object

RPCManager is a static singleton class that manages transparent client/server RPC (remote procedure call). This class provides a generic, low-level client/server communication integration point.

Smart GWT's powerful databinding subsystem (see DataSource, DataBoundComponents) automatically make use of this class to issue RPCs as necessary, based on the DataSource protocol. To integrate DataBoundComponents with your server, start here.

For arbitrary client/server interactions outside of the DataSource subsystem, the Smart GWT server also provides the Direct Method Invocation feature.

The RPCManager class can also be used directly to send data to a URL of your choosing and optionally be called back with server-returned data when the server replies.

The Smart GWT server code has APIs for processing RPC requests providing features such as automatic Java <--> JavaScript object translation and handling of queued requests.
The IDACall servlet makes use of these features to handle standard DataSource requests and DMI calls. Developers can also override the actionURL of specific requests and use these APIs directly in a JSP, Servlet or Filter.

Note: the client-side RPCManager class can also be used without the Smart GWT server. For an overview of client/server interactions without the Smart GWT server, see this overview.

Simple arbitrary Remote Procedure Call example (client code):

   RPCRequest request = new RPCRequest();
   // Note data could be a String, Map or Record
   request.setData("Some data to send to the client");
   request.setActionURL("/rpcHandler.jsp");
  
   RPCManager.sendRequest(request, 
       new RPCCallback () {
           public void execute(RPCResponse response, Object rawData, RPCRequest request) {
               SC.say("Response from the server:" + rawData);
           }
       }
   );
  

Simple arbitrary Remote Procedure Call example (server code: /rpcHandler.jsp):

RPCManager rpc = new RPCManager(request, response, out);
Object data = rpc.getData();
System.out.println("client sent: " + data.toString());
rpc.send("here's a response");

Queuing
Because of browser limitations on the total number of simultaneous HTTP connections to a given server, batching multiple RPC requests into a single HTTP request is highly advisable whenever possible. The RPCManager provides a queuing mechanism that allows this.

Queuing example (client code):

   boolean wasQueuing = RPCManager.startQueue();
   
   RPCCallback callback = new RPCCallback() {
       public void execute(RPCResponse response, Object rawData, RPCRequest request) {
           Window.alert("response from server:" + rawData);
       }
   };
    
   RPCRequest request1 = new RPCRequest();
   request1.setActionURL("/rpcHandler.jsp");
   request1.setData("A String of Data");
   RPCManager.sendRequest(request1, callback);
    
   RPCRequest request2 = new RPCRequest();
   request2.setActionURL("/rpcHandler.jsp");
   request2.setData("Another String of Data");
   RPCManager.sendRequest(request2, callback);
    
   if (!wasQueuing) RPCManager.sendQueue();
  

Queuing example (server code: /rpcHandler.jsp):

RPCManager rpc = new RPCManager(request, response, out);
for(Iterator i = rpc.getRequests().iterator(); i.hasNext();) {
    RPCRequest rpcRequest = (RPCRequest)i.next();
    Object data = rpcRequest.getData();
    System.out.println("client sent:" + data.toString());
    //send back the data sent to us by the client
    rpc.send(rpcRequest, new RPCResponse(data));
}


Error Handling

Please see this separate article on error handling.


Field Summary
static String ALL_GLOBALS
          ALL_GLOBALS constant used by the loadScreen(String, LoadScreenCallback, String[]) API.
 
Constructor Summary
RPCManager()
           
 
Method Summary
static void cancelQueue()
          Cancel a queue of requests (also called a transaction).
static void cancelQueue(String transactionNum)
          Cancel a queue of requests (also called a transaction).
static void clearTransaction(String transactionNum)
          Erase all client-side record of a transaction, such that any response from the server will be ignored.
static void exportContent(Canvas canvas)
          Converts printable HTML generated from live UI components into a .pdf and downloads it ("Save As.." dialog).
static void exportContent(Canvas canvas, DSRequest requestProperties)
          Converts printable HTML generated from live UI components into a .pdf and downloads it ("Save As.." dialog).
static String getCurrentTransactionId()
          Returns the id of the current transaction (a queue of requests).
static void loadScreen(String screenName, LoadScreenCallback callback)
          Loads a screen saved in Component XML format, using the ScreenLoaderServlet.
static void loadScreen(String screenName, LoadScreenCallback callback, String[] globals)
          Loads a screen saved in Component XML format, using the ScreenLoaderServlet.
static void loadScreen(String screenName, LoadScreenCallback callback, String[] globals, RPCRequest requestProperties)
          Loads a screen saved in Component XML format, using the ScreenLoaderServlet.
static Boolean requestsArePending()
          Returns whether there are any pending RPC requests.
static void resendTransaction()
          Resend a suspended transaction to the server.
static void resendTransaction(String transactionNum)
          Resend a suspended transaction to the server.
static void send(JavaScriptObject data, RPCCallback callback, Map requestParams)
          This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().
static void send(JavaScriptObject data, RPCCallback callback, RPCRequest requestParams)
          This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().
static void send(String data, RPCCallback callback, Map requestParams)
          This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().
static void send(String data, RPCCallback callback, RPCRequest requestParams)
          This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().
static void sendProxied(RPCRequest request)
          Send an HTTP request to a remote host, potentially through the HttpProxy servlet installed on the Smart GWT Server.
static void sendProxied(RPCRequest request, RPCCallback callback)
          Send an HTTP request to a remote host, potentially through the HttpProxy servlet installed on the Smart GWT Server.
static void sendQueue()
          Send all currently queued requests to the server.
static void sendQueue(RPCQueueCallback callback)
          Send all currently queued requests to the server.
static void sendRequest(RPCRequest rpcRequestProperties)
          Send the passed RPCRequest to the server.
static void sendRequest(RPCRequest rpcRequestProperties, RPCCallback callback)
          Send the passed RPCRequest to the server.
static void setActionURL(String actionURL)
          The actionURL specifies the URL to which the RPC request will be sent.
static void setAllowCrossDomainCalls(Boolean allowCrossDomainCalls)
          By default SmartGWT will show a warning message on attempted requests to another domain as this is usually not supported at the browser level by default due to security considerations.
static void setAllowIE9Leak(boolean allowLeak)
          In Internet Explorer 9, when a string of JavaScript is evaluated via the native eval() function, objects created within that evaluation are not released from browser memory until the page is reloaded.
static void setCredentialsURL(String credentialsURL)
          Specifies URL where credentials should be submitted to attempt relogin when session timeout is encountered during a background RPC.
static void setDefaultPrompt(String defaultPrompt)
          If showPrompt is enabled for a given transaction, this is the defaultPrompt to be shown to the user in a modal dialog while the transaction occurs.
static void setDefaultTimeout(double defaultTimeout)
          In milliseconds, how long the RPCManager waits for an RPC request to complete before returning an error.
static void setFetchDataPrompt(String fetchDataPrompt)
          Default prompt displayed to the user while an operation is running to fetch data from the server.
static void setHandleErrorCallback(HandleErrorCallback callback)
          By default handleError() always logs a warning.
static void setHandleTransportErrorCallback(HandleTransportErrorCallback callback)
          Method to handle server error responses to submitted transactions.
static void setLoginRequiredCallback(LoginRequiredCallback callback)
          The rpcRequest parameter can be used to determine whether the suspended transaction can simply be dropped (eg, it's periodic polling request).
static void setPromptCursor(String promptCursor)
          Controls the default cursor shown when RPCManager.promptStyle is set to "cursor".
static void setPromptStyle(PromptStyle promptStyle)
          Controls the default prompt style.
static void setQueueSentCallback(QueueSentCallback callback)
          Register a callback that is called by the RPCManager every time it sends a queue of requests to the server (note that if you not using queuing, the system simply sends queues containing just one request, so this API is valid regardless).
static void setRemoveDataPrompt(String removeDataPrompt)
          Default prompt displayed to user while an opration is running to remove data from the server.
static void setSaveDataPrompt(String saveDataPrompt)
          Default prompt displayed to the user while an opreration is running to save data to the server.
static void setShowPrompt(boolean showPrompt)
          If set to true, the RPCManager will block the UI with a modal dialog containing the text from RPCManager.defaultPrompt (or the per-RPCRequest override) until the RPC to the server completes.
static void setTimeoutErrorMessage(String timeoutErrorMessage)
          Default message displayed to user when an opration fails to return from the server within the timeout period specified by RPCManager.defaultTimeout.
static void setUseCursorTracking(boolean useCursorTracking)
          If true, an image is shown to the right of the cursor when RPCRequest.promptStyle is set to "cursor", otherwise the cursor itself is modified via css to the value of RPCRequest.promptCursor.
static void setUseHttpProxy(Boolean useProxy)
          Whether to ever attempt to use the "HttpProxy" servlet to enable web service requests to servers other than the origin server.
static boolean startQueue()
          Start queuing requests.
static void suspendTransaction()
          Suspends the current transaction, such that all processing of the transaction is halted, any remaining callback in the transaction won't fire, and the transaction can never timeout.
static void suspendTransaction(String transactionID)
          Suspends the current transaction, such that all processing of the transaction is halted, any remaining callback in the transaction won't fire, and the transaction can never timeout.
static Boolean xmlHttpRequestAvailable()
          Returns true if the XMLHttpRequest object is available, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_GLOBALS

public static final String ALL_GLOBALS
ALL_GLOBALS constant used by the loadScreen(String, LoadScreenCallback, String[]) API.

See Also:
Constant Field Values
Constructor Detail

RPCManager

public RPCManager()
Method Detail

cancelQueue

public static void cancelQueue()
Cancel a queue of requests (also called a transaction).

If a transactionId is passed, that transaction will be cancelled, otherwise, the current (not yet sent) transaction is cancelled. You can retrieve the id of the current transaction, if there is one, by calling getCurrentTransactionId() before the transaction has been sent.

Note that cancelQueue() calls clearTransaction() and attempts to abort the request. However, note also that whilst cancelling a transaction that has already been sent will not necessarily stop the HTTP request that has been issued - this is only possible on some browsers and with some transports - it will reliably cause Smart GWT to ignore any response returned by the server and not fire any callbacks that have been passed in.


cancelQueue

public static void cancelQueue(String transactionNum)
Cancel a queue of requests (also called a transaction).

If a transactionId is passed, that transaction will be cancelled, otherwise, the current (not yet sent) transaction is cancelled. You can retrieve the id of the current transaction, if there is one, by calling getCurrentTransactionId() before the transaction has been sent.

Note that cancelQueue() calls clearTransaction() and attempts to abort the request. However, note also that whilst cancelling a transaction that has already been sent will not necessarily stop the HTTP request that has been issued - this is only possible on some browsers and with some transports - it will reliably cause Smart GWT to ignore any response returned by the server and not fire any callbacks that have been passed in.

Parameters:
transactionNum - transactionId of the queue.

clearTransaction

public static void clearTransaction(String transactionNum)
Erase all client-side record of a transaction, such that any response from the server will be ignored.

A transaction means a batch of one or more RPCRequests that have already been sent to the server via RPCManager.sendQueue.

You can retrieve the id of the current transaction, if there is one, by getCurrentTransactionId() before the transaction is sent.

Parameters:
transactionNum - id of the transaction to be cleared

exportContent

public static void exportContent(Canvas canvas)
Converts printable HTML generated from live UI components into a .pdf and downloads it ("Save As.." dialog).

For DrawPane and subclasses (e.g. FacetChart) to export properly, the canvas parameter must be the widget itself, not the HTML obtained with getPrintHTML().

You can use a custom skin when exporting your HTML content. To use a custom skin, add a line to server.properties:

    skin.{skinName}.location: custom/skin
  
Where {skinName} is the name of your custom skin, and the value is the path to your skin resources from the application webroot.

Requires the Smart GWT server framework, but does not require use of server-based databinding - no .ds.xml files need to exist.

See server-side docs for com.isomorphic.contentexport.PdfExport for more details on server-side processing and code samples for redirecting PDF output to a file or in-memory buffer, as well as instructions for adding additional stylesheets.

Parameters:
canvas - Canvas that has exportable widgets, or HTML fragment derived from getPrintHTML()

exportContent

public static void exportContent(Canvas canvas,
                                 DSRequest requestProperties)
Converts printable HTML generated from live UI components into a .pdf and downloads it ("Save As.." dialog).

For DrawPane and subclasses (e.g. FacetChart) to export properly, the canvas parameter must be the widget itself, not the HTML obtained with getPrintHTML().

You can use a custom skin when exporting your HTML content. To use a custom skin, add a line to server.properties:

    skin.{skinName}.location: custom/skin
  
Where {skinName} is the name of your custom skin, and the value is the path to your skin resources from the application webroot.

Requires the Smart GWT server framework, but does not require use of server-based databinding - no .ds.xml files need to exist.

See server-side docs for com.isomorphic.contentexport.PdfExport for more details on server-side processing and code samples for redirecting PDF output to a file or in-memory buffer, as well as instructions for adding additional stylesheets.

Parameters:
canvas - Canvas that has exportable widgets, or HTML fragment derived from getPrintHTML()
requestProperties - Request properties for the export to pdf object

requestsArePending

public static Boolean requestsArePending()
Returns whether there are any pending RPC requests.

Returns:
true if one or more RPC requests are pending, false otherwise.

resendTransaction

public static void resendTransaction()
Resend a suspended transaction to the server. See RPCManager.suspendTransaction for context.

Note that the transaction must have been previously suspended, and in particular suspended validly according to the rules described in the docs for RPCManager.suspendTransaction, or undefined results will occur.

You can resend all suspended transactions by calling RPCManager.resendTransaction with no arguments.


resendTransaction

public static void resendTransaction(String transactionNum)
Resend a suspended transaction to the server. See RPCManager.suspendTransaction for context.

Note that the transaction must have been previously suspended, and in particular suspended validly according to the rules described in the docs for RPCManager.suspendTransaction, or undefined results will occur.

You can resend all suspended transactions by calling RPCManager.resendTransaction with no arguments.

Parameters:
transactionNum - id of the transaction to be re-sent, or null to resend all suspended transactions

xmlHttpRequestAvailable

public static Boolean xmlHttpRequestAvailable()
Returns true if the XMLHttpRequest object is available, false otherwise. See PlatformDependencies for more information on when XMLHttpRequest parser may not available and what features are impacted as a result.

Returns:
true if XMLHttpRequest is available, false otherwise.

setActionURL

public static void setActionURL(String actionURL)
The actionURL specifies the URL to which the RPC request will be sent. Note that if you override this global default and your application uses DataSource databound components, you'll need to dispatch the DataSource requests from your RPC handler. Your other option is to specify a url on a per-request basis.

Parameters:
actionURL - the action URL.

setCredentialsURL

public static void setCredentialsURL(String credentialsURL)
Specifies URL where credentials should be submitted to attempt relogin when session timeout is encountered during a background RPC.

Parameters:
credentialsURL - default value http://localhost:8080/isomorphic/login/loginSuccessMarker.html

setDefaultTimeout

public static void setDefaultTimeout(double defaultTimeout)

In milliseconds, how long the RPCManager waits for an RPC request to complete before returning an error. If set to zero, the RPCManager will not enforce a timeout, but note that most browsers enforce their own timeouts on HTTP requests.

For the "xmlHttpRequest" transport, this timeout can only happen if the server actually fails to respond within the specified number of milliseconds. For the "hiddenFrames" transport, this timeout will occur for non-200 (HTTP_OK) responses.

Parameters:
defaultTimeout - the default value is 240000 [4 minutes]

setDefaultPrompt

public static void setDefaultPrompt(String defaultPrompt)
If showPrompt is enabled for a given transaction, this is the defaultPrompt to be shown to the user in a modal dialog while the transaction occurs. May be overridden at the request level via RPCRequest.prompt.

More targetted default prompts are also supported for certain code-paths. See the following set of properties for details:

Parameters:
defaultPrompt - the default value is 'Contacting Server...'

setFetchDataPrompt

public static void setFetchDataPrompt(String fetchDataPrompt)
Default prompt displayed to the user while an operation is running to fetch data from the server. Displayed as a result of ListGrid.filterData(), ListGrid.fetchData() and ListGrid.clearCriteria() code paths.

Parameters:
fetchDataPrompt - defaults to "Finding Records that match your criteria..."

setRemoveDataPrompt

public static void setRemoveDataPrompt(String removeDataPrompt)
Default prompt displayed to user while an opration is running to remove data from the server. Displayed as a result of the ListGrid.removeSelectedData() code path.

Parameters:
removeDataPrompt - default value "Deleting Record(s)..."

setSaveDataPrompt

public static void setSaveDataPrompt(String saveDataPrompt)
Default prompt displayed to the user while an opreration is running to save data to the server. Displayed as a result of the DynamicForm.saveData() code path.

Parameters:
saveDataPrompt - default value "Saving form..."

setPromptCursor

public static void setPromptCursor(String promptCursor)
Controls the default cursor shown when RPCManager.promptStyle is set to "cursor". Overrideable by RPCRequest.promptCursor. In Safari, IE 5.5 and Firefox 1.0 the default value is "wait", on all other platforms it is "progress". The reason for this split is that the above-mentioned browsers do not support CSS2.1 - which is required for the "progress" cursor type.

Parameters:
promptCursor - default is browser dependant

setPromptStyle

public static void setPromptStyle(PromptStyle promptStyle)
Controls the default prompt style. Overrideable by RPCRequest.promptStyle.

Parameters:
promptStyle - default is PromptStyle.DIALOG

setShowPrompt

public static void setShowPrompt(boolean showPrompt)
If set to true, the RPCManager will block the UI with a modal dialog containing the text from RPCManager.defaultPrompt (or the per-RPCRequest override) until the RPC to the server completes.

If set to false, the RPC happens transparently, allowing the user to continue interacting with the UI

Parameters:
showPrompt - default is false

setTimeoutErrorMessage

public static void setTimeoutErrorMessage(String timeoutErrorMessage)
Default message displayed to user when an opration fails to return from the server within the timeout period specified by RPCManager.defaultTimeout.

Parameters:
timeoutErrorMessage - default value is "Operation timed out"

setUseCursorTracking

public static void setUseCursorTracking(boolean useCursorTracking)
If true, an image is shown to the right of the cursor when RPCRequest.promptStyle is set to "cursor", otherwise the cursor itself is modified via css to the value of RPCRequest.promptCursor. The default is platform-dependent. In Safari, IE 5.5 and Firefox 1.0 the default is true, on all other platforms it is false. The reason for this split is that, the above browsers require that the cursor move before CSS settings are re-evaluated - this means the progress cursor can stick until the user moves the mouse.

This value can be overridden on a per-request basis via RPCRequest.useCursorTracker.

Parameters:
useCursorTracking - default value is platform-dependant

setUseHttpProxy

public static void setUseHttpProxy(Boolean useProxy)
Whether to ever attempt to use the "HttpProxy" servlet to enable web service requests to servers other than the origin server.

Parameters:
useProxy - enable or disable attempting to use the "HttpProxy" servlet

setAllowCrossDomainCalls

public static void setAllowCrossDomainCalls(Boolean allowCrossDomainCalls)
By default SmartGWT will show a warning message on attempted requests to another domain as this is usually not supported at the browser level by default due to security considerations.

Some browsers now do support cross domain requests through the use of Http Access Control headers (See the http://www.w3.org/TR/cors/,W3C Cross-Origin Resource Sharing recommendation). If your application intends to rely on this behavior to perform cross-domain requests, you can set allowCrossDomainCalls to true to disable the standard SmartGWT warning when such calls occur.

Note also that this is typically not an issue if you are using the SmartGWT server (part of Pro, Power and Enterprise editions of SmartClient), as this includes the HTTPProxy servlet.

Parameters:
-

setLoginRequiredCallback

public static void setLoginRequiredCallback(LoginRequiredCallback callback)
The rpcRequest parameter can be used to determine whether the suspended transaction can simply be dropped (eg, it's periodic polling request).

The rpcResponse parameter has rpcResponse.data set to the raw text of the response that triggered loginRequired(). Some very advanced relogin strategies may need to inspect the raw response to get information needed for re-authentication.

Parameters:
callback - the LoginRequiredCallback

setHandleErrorCallback

public static void setHandleErrorCallback(HandleErrorCallback callback)
By default handleError() always logs a warning. In addition, if response.data was set to a String, a warning dialog will be shown to the user with response.data as the message, which allows the server to send user error messages back without writing custom client-side error handling.

To do custom error handling that is specific to a particular component or type of request, set RPCRequest.willHandleError and deal with errors in the rpcRequest.callback. To change the default system-wide error handling, register this callback.

If you're using the xmlHttpRequest RPCRequest.transport, you can access the HTTP status code of the response (eg 404 Not Found or 500 Server Error) as RPCResponse.httpResponseCode.

For very advanced usage, the response.xmlHttpRequest contains the native XMLHttpRequest object used to make the request. Accessing this object is subject to possible cross-platform bugs and inconsistencies, and we recommend that you wrap any access to the XMLHttpRequest object in a try/catch block because some browsers may throw exceptions when certain attributes of this object are accessed. For example, if you try to access XMLHttpRequest.status (for the HTTP status code) when the network cable is unpluged in Windows, you'll get an Exception in Firefox. See ErrorHandling for an overview of SmartGWT error handling.

Parameters:
callback - the callback

setHandleTransportErrorCallback

public static void setHandleTransportErrorCallback(HandleTransportErrorCallback callback)
Method to handle server error responses to submitted transactions. When the server responds to a submitted transaction with an HTTP error code this method will be called before any individual response callbacks are fired, regardless of whether RPCRequest.willHandleError was specified on the submitted request[s].

This provides the developer with an opportunity to handle a server error by (for example) suspending and resubmitting the transaction before any other handling occurs.

The default implementation takes no action - by default transport errors are handled via {#setHandleErrorCallback()}, or by the standard request callback methods, depending on request.willHandleError. See ErrorHandling for an overview of SmartGWT error handling.

Parameters:
callback - the handleTransportError callback

startQueue

public static boolean startQueue()
Start queuing requests. When queuing requests, an HTTP request will not be sent to the server until RPCManager.sendQueue() is called.

All requests in a given queue must go to the same actionURL and use the same transport (XMLHttp or frames). If a request specifies a different actionURL or transport than that of the requests currently on the queue, it will be sent to the server separately, ahead of the queue, and a warning will be logged to the Developer Console.

Note that the server must process all requests sent as part of the queue before any response is sent to the client. You should avoid batching a request that will take a long time to process on the server with any other requests because it will delay the response of all requests in the queue.

Returns:
whether queuing was already enabled before we called

sendQueue

public static void sendQueue()
Send all currently queued requests to the server. You need only call this method if you are using queuing otherwise your requests are synchronously submitted to the server.

NOTE: if you aren't the caller who first enables queuing (startQueue() returns true), you should in general avoid calling sendQueue(), because whoever was first to enable queuing may have more requests to add to the same queue.


sendQueue

public static void sendQueue(RPCQueueCallback callback)
Send all currently queued requests to the server. You need only call this method if you are using queuing otherwise your requests are synchronously submitted to the server.

NOTE: if you aren't the caller who first enables queuing (startQueue() returns true), you should in general avoid calling sendQueue(), because whoever was first to enable queuing may have more requests to add to the same queue.


suspendTransaction

public static void suspendTransaction()
Suspends the current transaction, such that all processing of the transaction is halted, any remaining callback in the transaction won't fire, and the transaction can never timeout.

suspendTransaction() is typically used to handle total failures for an entire transaction, such as HTTP status 500, or session timeout resulting in com.smartgwt.client.rpc.RPCManager#loginRequired being called. In both cases the intent is to put the transaction on hold so that a transient problem can be resolved, and then the transaction can be re-sent successfully. By using suspendTransaction(), components that submitted requests never realize there was a transient failure, and so error handling logic does not have to be implemented in every component.

Generally you can only validly suspend a transaction from either com.smartgwt.client.rpc.RPCManager#loginRequired or com.smartgwt.client.rpc.RPCManager#handleError, and in the case of handleError(), only when the first response in the transaction has an error. Suspending and re-sending a partially processed transaction means that some responses will be processed twice, with undefined results for requests issued automatically by UI components.

A suspended transaction must ultimately be either cleared via clearTransaction(java.lang.String) or re-sent via resendTransaction() or memory will be leaked.


suspendTransaction

public static void suspendTransaction(String transactionID)
Suspends the current transaction, such that all processing of the transaction is halted, any remaining callback in the transaction won't fire, and the transaction can never timeout.

suspendTransaction() is typically used to handle total failures for an entire transaction, such as HTTP status 500, or session timeout resulting in com.smartgwt.client.rpc.RPCManager#loginRequired being called. In both cases the intent is to put the transaction on hold so that a transient problem can be resolved, and then the transaction can be re-sent successfully. By using suspendTransaction(), components that submitted requests never realize there was a transient failure, and so error handling logic does not have to be implemented in every component.

Generally you can only validly suspend a transaction from either com.smartgwt.client.rpc.RPCManager#loginRequired or com.smartgwt.client.rpc.RPCManager#handleError, and in the case of handleError(), only when the first response in the transaction has an error. Suspending and re-sending a partially processed transaction means that some responses will be processed twice, with undefined results for requests issued automatically by UI components.

A suspended transaction must ultimately be either cleared via clearTransaction(java.lang.String) or re-sent via resendTransaction() or memory will be leaked.

Parameters:
transactionID - transaction to delay. Defaults to the current transaction if there is one

getCurrentTransactionId

public static String getCurrentTransactionId()
Returns the id of the current transaction (a queue of requests).

This method must be called after startQueue() has been called and at least one request has been issued.

Returns:
the transactionNum of the current transaction.

setQueueSentCallback

public static void setQueueSentCallback(QueueSentCallback callback)

Register a callback that is called by the RPCManager every time it sends a queue of requests to the server (note that if you not using queuing, the system simply sends queues containing just one request, so this API is valid regardless).

It is intended to be used by user code that needs to be notified when Smart GWT sends requests to the server. Note that the list of RPCRequest's passed to this callback is strictly read-only.

Parameters:
callback - the callback

sendProxied

public static void sendProxied(RPCRequest request)
Send an HTTP request to a remote host, potentially through the HttpProxy servlet installed on the Smart GWT Server.

This API allows contacting services which are hosted on servers other than the origin server if the HttpProxy servlet is enabled on the Smart GWT Server.

The HttpProxy will be used if the actionURL starts with "http" and uses a hostname other than "localhost" or window.location.hostname, or if the port number differs, or if request.useHttpProxy is explicitly set. Otherwise the request goes to the origin server (the server that returned the current page).

The RPCRequest properties that will be respected when relaying requests via the HttpProxy are: actionURL, httpMethod, params, contentType, httpHeaders, and data. In this case "data", if set, will be used as the request body for an HTTP POST.

Higher-level APIs like DataSource or WebService call through this API, and so automatically use the HttpProxy if dataURL or webService.location is set to a foreign server.

This API is only suitable for direct use when loading unstructured data that will not be shown in a DataBoundComponent. For a WSDL-described web service, use XMLTools.loadWSDL instead. For other web services, use a DataSource with dataURL, and use DataSource.transformRequest and DataSource.transformResponse as necessary to form requests for the service and transform responses for display.

Parameters:
request - rpcRequest to be routed through the HttpProxy

sendProxied

public static void sendProxied(RPCRequest request,
                               RPCCallback callback)
Send an HTTP request to a remote host, potentially through the HttpProxy servlet installed on the Smart GWT Server.

This API allows contacting services which are hosted on servers other than the origin server if the HttpProxy servlet is enabled on the Smart GWT Server.

The HttpProxy will be used if the actionURL starts with "http" and uses a hostname other than "localhost" or window.location.hostname, or if the port number differs, or if request.useHttpProxy is explicitly set. Otherwise the request goes to the origin server (the server that returned the current page).

The RPCRequest properties that will be respected when relaying requests via the HttpProxy are: actionURL, httpMethod, params, contentType, httpHeaders, and data. In this case "data", if set, will be used as the request body for an HTTP POST.

Higher-level APIs like DataSource or WebService call through this API, and so automatically use the HttpProxy if dataURL or webService.location is set to a foreign server.

This API is only suitable for direct use when loading unstructured data that will not be shown in a DataBoundComponent. For a WSDL-described web service, use XMLTools.loadWSDL instead. For other web services, use a DataSource with dataURL, and use DataSource.transformRequest and DataSource.transformResponse as necessary to form requests for the service and transform responses for display.

Parameters:
request - rpcRequest to be routed through the HttpProxy
callback - callback to invoke on RPC completion

sendRequest

public static void sendRequest(RPCRequest rpcRequestProperties)
Send the passed RPCRequest to the server. If queuing is in effect, this queues the request instead.

Parameters:
rpcRequestProperties - RPCRequest to send to the server

sendRequest

public static void sendRequest(RPCRequest rpcRequestProperties,
                               RPCCallback callback)
Send the passed RPCRequest to the server. If queuing is in effect, this queues the request instead.

Parameters:
rpcRequestProperties - RPCRequest to send to the server
callback - callback to invoke on RPC completion

send

public static void send(String data,
                        RPCCallback callback,
                        RPCRequest requestParams)
This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().

Parameters:
data - data to be passed to the server
callback - callback to invoke on RPC completion
requestParams - any additional properties you want to set - these will be applied to the RPCRequest object that will be auto-created for you.

send

public static void send(String data,
                        RPCCallback callback,
                        Map requestParams)
This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().

Parameters:
data - data to be passed to the server
callback - callback to invoke on RPC completion
requestParams - any additional properties you want to set - these will be applied to the RPCRequest object that will be auto-created for you.

send

public static void send(JavaScriptObject data,
                        RPCCallback callback,
                        RPCRequest requestParams)
This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().

Parameters:
data - data to be passed to the server
callback - callback to invoke on RPC completion
requestParams - any additional properties you want to set - these will be applied to the RPCRequest object that will be auto-created for you.

send

public static void send(JavaScriptObject data,
                        RPCCallback callback,
                        Map requestParams)
This method is a convenience wrapper on RPCManager.sendRequest() - it calls through to sendRequest().

Parameters:
data - data to be passed to the server
callback - callback to invoke on RPC completion
requestParams - any additional properties you want to set - these will be applied to the RPCRequest object that will be auto-created for you.

loadScreen

public static void loadScreen(String screenName,
                              LoadScreenCallback callback)
Loads a screen saved in Component XML format, using the ScreenLoaderServlet.

For each screenName passed, the ScreenLoaderServlet will look for a file named screenName.ui.xml in the directory given by the "project.ui" setting, which defaults webroot/shared/ui and can be configured in server.properties.

By default, components in the loaded screen that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

This API assumes the ScreenLoaderServlet is installed at the default location - to use a different location, use the requestProperties parameter to specify a different URL via actionURL. The requestProperties parameter can also be used to pass additional params to a custom ScreenLoaderServlet - see the "Dynamic Component XML" section of the Component XML overview.

Parameters:
screenName - name of the screen to load
callback - callback for notification of screen being loaded

loadScreen

public static void loadScreen(String screenName,
                              LoadScreenCallback callback,
                              String[] globals)
Loads a screen saved in Component XML format, using the ScreenLoaderServlet.

For each screenName passed, the ScreenLoaderServlet will look for a file named screenName.ui.xml in the directory given by the "project.ui" setting, which defaults webroot/shared/ui and can be configured in server.properties.

By default, components in the loaded screen that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

This API assumes the ScreenLoaderServlet is installed at the default location - to use a different location, use the requestProperties parameter to specify a different URL via actionURL. The requestProperties parameter can also be used to pass additional params to a custom ScreenLoaderServlet - see the "Dynamic Component XML" section of the Component XML overview.

Parameters:
screenName - name of the screen to load
callback - callback for notification of screen being loaded
globals - widgets to allow to take their global IDs

loadScreen

public static void loadScreen(String screenName,
                              LoadScreenCallback callback,
                              String[] globals,
                              RPCRequest requestProperties)
Loads a screen saved in Component XML format, using the ScreenLoaderServlet.

For each screenName passed, the ScreenLoaderServlet will look for a file named screenName.ui.xml in the directory given by the "project.ui" setting, which defaults webroot/shared/ui and can be configured in server.properties.

By default, components in the loaded screen that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

This API assumes the ScreenLoaderServlet is installed at the default location - to use a different location, use the requestProperties parameter to specify a different URL via actionURL. The requestProperties parameter can also be used to pass additional params to a custom ScreenLoaderServlet - see the "Dynamic Component XML" section of the Component XML overview.

Parameters:
screenName - name of the screen to load
callback - callback for notification of screen being loaded
globals - widgets to allow to take their global IDs
requestProperties - optional properties for the request

setAllowIE9Leak

public static void setAllowIE9Leak(boolean allowLeak)
In Internet Explorer 9, when a string of JavaScript is evaluated via the native eval() function, objects created within that evaluation are not released from browser memory until the page is reloaded.

SmartGWT uses the eval() function to evaluate JSON formatted responses to RPCRequests by default, making long running applications potentially susceptible to memory leaks over time.

Setting this property to false enables a workaround suggested on the Microsoft Knowledge Base to avoid such memory leaks by evaluating script in a hidden iframe and periodically refresh that frame. However developers should be aware of the following limitation with this setting: attempting to access certain object types including Date or function objects generated from such an evaluation can subsequently lead to a JavaScript error with the message "Can't execute code from a freed script".

This workaround therefore may not be suitable for all transactions or dataSources within a given application.

This property may also be specified for specific +link{RPCRequest.allowIE9Leak,RPCRequests}.

Note: This issue is discussed further in the online SmartGWT FAQ.