com.smartgwt.client.rpc

## Class RPCResponse

- java.lang.Object
- - com.smartgwt.client.core.JsObject
  - - com.smartgwt.client.core.DataClass
    - - com.smartgwt.client.rpc.RPCResponse

- Direct Known Subclasses:
    DSResponse

      public class RPCResponse
      extends DataClass

  Encapsulates an RPC response from the server. Instances of this class are automatically created and optionally passed to you in the callback you specify as part of your RPCRequest.
  See Also:
    `RPCRequest`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `STATUS_FAILURE`
    `static int` | `STATUS_LOGIN_INCORRECT`
    `static int` | `STATUS_LOGIN_REQUIRED`
    `static int` | `STATUS_LOGIN_SUCCESS`
    `static int` | `STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED`
    `static int` | `STATUS_SERVER_TIMEOUT`
    `static int` | `STATUS_SUCCESS`
    `static int` | `STATUS_TRANSPORT_ERROR`
    `static int` | `STATUS_VALIDATION_ERROR`

    - ### Fields inherited from class com.smartgwt.client.core.JsObject

      `jsObj`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RPCResponse()`
    `RPCResponse(com.google.gwt.core.client.JavaScriptObject jsObj)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `create()` RPCResponses shouldn't be created directly.
    `java.util.Map` | `getDataAsMap()` The data sent by the server.
    `com.google.gwt.core.client.JavaScriptObject` | `getDataAsObject()` The data sent by the server.
    `java.lang.String` | `getDataAsString()` The data sent by the server.
    `java.util.Map` | `getHttpHeaders()` HTTP headers returned by the server, as a Map of Header name -> Header value
    `java.lang.Integer` | `getHttpResponseCode()` This attribute (available when using the the `xmlHttpRequest` transport) contains the HTTP response code sent by the server.
    `java.lang.String` | `getHttpResponseText()` The actual text of the HTTP response.
    `static RPCResponse` | `getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `int` | `getStatus()` Status code for this response.
    `java.lang.Integer` | `getTransactionNum()` ID of the transaction sent to the server via `RPCManager.sendQueue` containing the `RPCRequest` associated with this response.
    `void` | `setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `void` | `setStatus(int status)` Status code for this response.

    - ### Methods inherited from class com.smartgwt.client.core.DataClass

      `doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject`

    - ### Methods inherited from class com.smartgwt.client.core.JsObject

      `equals, hashCode, isCreated, setJsObj`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### STATUS_FAILURE

          public static final int STATUS_FAILURE

      See Also:
        Constant Field Values

    - #### STATUS_LOGIN_INCORRECT

          public static final int STATUS_LOGIN_INCORRECT

      See Also:
        Constant Field Values

    - #### STATUS_LOGIN_REQUIRED

          public static final int STATUS_LOGIN_REQUIRED

      See Also:
        Constant Field Values

    - #### STATUS_LOGIN_SUCCESS

          public static final int STATUS_LOGIN_SUCCESS

      See Also:
        Constant Field Values

    - #### STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED

          public static final int STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED

      See Also:
        Constant Field Values

    - #### STATUS_SERVER_TIMEOUT

          public static final int STATUS_SERVER_TIMEOUT

      See Also:
        Constant Field Values

    - #### STATUS_SUCCESS

          public static final int STATUS_SUCCESS

      See Also:
        Constant Field Values

    - #### STATUS_TRANSPORT_ERROR

          public static final int STATUS_TRANSPORT_ERROR

      See Also:
        Constant Field Values

    - #### STATUS_VALIDATION_ERROR

          public static final int STATUS_VALIDATION_ERROR

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RPCResponse

          public RPCResponse()

    - #### RPCResponse

          public RPCResponse(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getOrCreateRef

          public static RPCResponse getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### setJavaScriptObject

          public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### getHttpResponseCode

          public java.lang.Integer getHttpResponseCode()

      This attribute (available when using the the `xmlHttpRequest` transport) contains the HTTP response code sent by the server.

      Note that this is different from `status` - that attribute is used to indicate a status code for the RPC itself whereas httpResponseCode is the raw HTTP response code for the HTTP request that contained the RPCRequest.

      This feature relies on the XMLHttpRequest object which can be disabled by end-users in some supported browsers. See `PlatformDependencies` for more information.

      If you're using this attribute, you'll typically want to avoid the default error handling response of RPCManager. To do so, set `willHandleError` to `true`.

      Returns:
        Integer

    - #### getHttpResponseText

          public java.lang.String getHttpResponseText()

      The actual text of the HTTP response. Only available when the default `RPCTransport` "xmlHttpRequest" transport is in use,
      Returns:
        . See `String`

    - #### setStatus

          public void setStatus(int status)

      Status code for this response. Status codes less than zero are considered errors by the RPCManager, those greater than or equal to zero are considered successes. Please see the error handling section the `RPCManager docs` for more information on what the RPCManager does with the status code and how you can override this behavior.

      When using the Smart GWT server you can set the rpcResponse.status by calling the server-side method RPCResponse.setStatus().

      When not using the Smart GWT server, the RPCManager makes no assumptions about the structure of the response, so the status code just reflects the `httpResponseCode`: status will be `STATUS_TRANSPORT_ERROR` if an HTTP-level error occurred such as "500 server error". If you have a status code you need to transmit you can simply embed it in the response (as part of `data`) and interpret it from the callback.

      With or without the Smart GWT server, the `Relogin` status codes (such as `STATUS_LOGIN_REQUIRED`) are triggered whenever special markers, such as the loginRequiredMarker, appear in the body of the response. See the `Relogin Overview` for details.

      Parameters:
        `status` - status

    - #### getStatus

          public int getStatus()

      Status code for this response. Status codes less than zero are considered errors by the RPCManager, those greater than or equal to zero are considered successes. Please see the error handling section the `RPCManager docs` for more information on what the RPCManager does with the status code and how you can override this behavior.

      When using the Smart GWT server you can set the rpcResponse.status by calling the server-side method RPCResponse.setStatus().

      When not using the Smart GWT server, the RPCManager makes no assumptions about the structure of the response, so the status code just reflects the `httpResponseCode`: status will be `STATUS_TRANSPORT_ERROR` if an HTTP-level error occurred such as "500 server error". If you have a status code you need to transmit you can simply embed it in the response (as part of `data`) and interpret it from the callback.

      With or without the Smart GWT server, the `Relogin` status codes (such as `STATUS_LOGIN_REQUIRED`) are triggered whenever special markers, such as the loginRequiredMarker, appear in the body of the response. See the `Relogin Overview` for details.

      Returns:
        int

    - #### getTransactionNum

          public java.lang.Integer getTransactionNum()

      ID of the transaction sent to the server via `RPCManager.sendQueue` containing the `RPCRequest` associated with this response.
      Returns:
        Integer

    - #### create

          public static void create()

      RPCResponses shouldn't be created directly. Instances of this class are automatically created and optionally passed to you in the callback you specify as part of your `RPCRequest`.

    - #### getHttpHeaders

          public java.util.Map getHttpHeaders()

      HTTP headers returned by the server, as a Map of Header name -> Header value

      Headers are available only when the default `RPCTransport` "xmlHttpRequest" is in use, and browsers may limit access to headers for cross-domain requests or in other security-sensitive scenarios.

      Returns:
        the http headers

    - #### getDataAsMap

          public java.util.Map getDataAsMap()

      The data sent by the server.

      When communicating with the SmartClient server, `rpcResponse.data` is the data passed to the server-side method `RPCResponse.setData()` by your Java code. This data is translated into JavaScript objects by the rules described under `rpcRequest.data` in the SmartClient Reference. Simple types (Numeric values, Strings, Dates, Booleans) will be available as their equivalent Java types in your client side GWT code. Complex objects (such as serialized `Map`s or `List`s from the server) will not be automatically translated back into Java on the client - they will arrive as `JavaScriptObject` instances. You can easily convert to the appropriate type yourself using the `JSOHelper` class. The `JSOHelper.convertToJava(JavaScriptObject, boolean)` method performs a recursive conversion of `JavaScriptObject`s returning a `List` (or array) for JavaScript arrays or a `Map` for simple JavaScript objects (key:value pairs).

      When not communicating with the SmartClient server `rpcResponse.data` contains the raw HTTP response body. See `rpcRequest.useSimpleHttp`, rpcRequest.serverOutputAsString, `rpcRequest.evalResult` in the SmartClient Reference for details.

      Returns:
        the data in the RPC response, as a Map
      See Also:
        `RPCRequest.setData(JavaScriptObject)`, `RPCRequest.setData(Map)`, `RPCRequest.setData(com.smartgwt.client.data.Record)`, `RPCRequest.setData(String)`

    - #### getDataAsString

          public java.lang.String getDataAsString()

      The data sent by the server.

      When communicating with the SmartClient server, `rpcResponse.data` is the data passed to the server-side method `RPCResponse.setData()` by your Java code. This data is translated into JavaScript objects by the rules described under `rpcRequest.data` in the SmartClient Reference. Simple types (Numeric values, Strings, Dates, Booleans) will be available as their equivalent Java types in your client side GWT code. Complex objects (such as serialized `Map`s or `List`s from the server) will not be automatically translated back into Java on the client - they will arrive as `JavaScriptObject` instances. You can easily convert to the appropriate type yourself using the `JSOHelper` class. The `JSOHelper.convertToJava(JavaScriptObject, boolean)` method performs a recursive conversion of `JavaScriptObject`s returning a `List` (or array) for JavaScript arrays or a `Map` for simple JavaScript objects (key:value pairs).

      When not communicating with the SmartClient server `rpcResponse.data` contains the raw HTTP response body. See `rpcRequest.useSimpleHttp`, rpcRequest.serverOutputAsString, `rpcRequest.evalResult` in the SmartClient Reference for details.

      Returns:
        the data in the RPC response, as a String
      See Also:
        `RPCRequest.setData(JavaScriptObject)`, `RPCRequest.setData(Map)`, `RPCRequest.setData(com.smartgwt.client.data.Record)`, `RPCRequest.setData(String)`

    - #### getDataAsObject

          public com.google.gwt.core.client.JavaScriptObject getDataAsObject()

      The data sent by the server.

      When communicating with the SmartClient server, `rpcResponse.data` is the data passed to the server-side method `RPCResponse.setData()` by your Java code. This data is translated into JavaScript objects by the rules described under `rpcRequest.data` in the SmartClient Reference. Simple types (Numeric values, Strings, Dates, Booleans) will be available as their equivalent Java types in your client side GWT code. Complex objects (such as serialized `Map`s or `List`s from the server) will not be automatically translated back into Java on the client - they will arrive as `JavaScriptObject` instances. You can easily convert to the appropriate type yourself using the `JSOHelper` class. The `JSOHelper.convertToJava(JavaScriptObject, boolean)` method performs a recursive conversion of `JavaScriptObject`s returning a `List` (or array) for JavaScript arrays or a `Map` for simple JavaScript objects (key:value pairs).

      When not communicating with the SmartClient server `rpcResponse.data` contains the raw HTTP response body. See `rpcRequest.useSimpleHttp`, rpcRequest.serverOutputAsString, `rpcRequest.evalResult` in the SmartClient Reference for details.

      Returns:
        the data in the RPC response, as a JavaScriptObject
      See Also:
        `RPCRequest.setData(JavaScriptObject)`, `RPCRequest.setData(Map)`, `RPCRequest.setData(com.smartgwt.client.data.Record)`, `RPCRequest.setData(String)`