Package com.isomorphic.rpc

# Class RPCResponse

java.lang.Object
com.isomorphic.base.Base
com.isomorphic.rpc.BaseResponse<RPCResponse>
com.isomorphic.rpc.RPCResponse

All Implemented Interfaces:
  `com.isomorphic.base.IAutoConfigurable`

public class RPCResponse extends BaseResponse<RPCResponse>
RPCResponse encapsulates data sent from the server to the client in response to an RPCRequest.

See Also:
  - `RPCManager`
  - `RPCRequest`
  - `JSTranslater`

- ## Field Summary

  ### Fields inherited from class com.isomorphic.rpc.BaseResponse

  `STATUS_AUTHORIZATION_FAILURE, STATUS_FAILURE, STATUS_FILE_NOT_FOUND, STATUS_FILE_REQUIRED_ERROR, STATUS_LOGIN_INCORRECT, STATUS_LOGIN_REQUIRED, STATUS_LOGIN_SUCCESS, STATUS_MAX_FILE_SIZE_EXCEEDED, STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED, STATUS_PROCESSING_SKIPPED, STATUS_REQUIRED_CRITERIA_MISSING, STATUS_SUCCESS, STATUS_TRANSACTION_FAILED, STATUS_UPDATE_WITHOUT_PK, STATUS_VALIDATION_ERROR, UPDATE_WITHOUT_PK`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RPCResponse()`
  Creates an empty RPCResponse.
  `RPCResponse(Object data)`
  Creates an RPCResponse with the provided data payload.
  Note: the status of this response is automatically set to the success code (RPCResponse.STATUS_SUCCESS)

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getData()`
  Retrives the data previosly set via setData() or the constructor that takes the data argument.
  `int`
  `getStatus()`
  Retrieves the currently set status code for this response.
  `RPCResponse`
  `setData(Object data)`
  Sets the response payload to be delivered to the client.
  `RPCResponse`
  `setStatus(int status)`
  Sets the status of this response.

  ### Methods inherited from class com.isomorphic.rpc.BaseResponse

  `setFailure, setSuccess, statusIsError, statusIsSuccess`

- ## Constructor Details

  - ### RPCResponse

    public RPCResponse()
    Creates an empty RPCResponse. If you use this constructor, you will need to call setData() to set the data you wish to be sent back to the client.

    Note: the status of this response is automatically set to the success code (RPCResponse.STATUS_SUCCESS); response is set to a success code (0)

  - ### RPCResponse

    public RPCResponse(Object data)
    Creates an RPCResponse with the provided data payload.
    Note: the status of this response is automatically set to the success code (RPCResponse.STATUS_SUCCESS)
    Parameters:
      `data` - the data you wish to send back.
    See Also:
      - `setData(Object)`

- ## Method Details

  - ### getData

    public Object getData()
    Retrives the data previosly set via setData() or the constructor that takes the data argument.

  - ### setData

    public RPCResponse setData(Object data)
    Sets the response payload to be delivered to the client.

    The object passed to setData() is translated to JavaScript via the JSTranslater class. Virtually anything passed to setData() will make it back to the browser in some reasonable representation; see JSTranslater for full documentation.

    You may call setData() any number of times, only the last provided value will be the value sent to the client.

    Parameters:
      `data` - the data you wish to send back.
    Returns:
      the RPCResponse
    See Also:
      - `JSTranslater.toJS(Object, Writer)`
      - `JSONFilter`

  - ### setStatus

    public RPCResponse setStatus(int status)
    Sets the status of this response. A zero status indicates succeess, a negative value indicates failure.

    Negative values will trigger error handling code on the client side - see the client-side reference for RPCManager.handleError(), rpcRequest.willHandleError.

    The default client-side behavior for a negative status code is that, if the data sent back (via setData()) is a String, it will be shown to the user in a warning dialog.

    Overrides:
      `setStatus` in class `BaseResponse<RPCResponse>`
    Parameters:
      `status` - the status code for this response
    Returns:
      the RPCResponse

  - ### getStatus

    public int getStatus()
    Retrieves the currently set status code for this response.
    Overrides:
      `getStatus` in class `BaseResponse<RPCResponse>`