com.smartgwt.client.data
Class DSResponse

java.lang.Object
  extended by com.smartgwt.client.core.JsObject
      extended by com.smartgwt.client.core.DataClass
          extended by com.smartgwt.client.rpc.RPCResponse
              extended by com.smartgwt.client.data.DSResponse

public class DSResponse
extends RPCResponse

Response sent by the server in response to a DataSource request. Contains all the properties available on the basic RPCResponse, in addition to the properties listed here.


Field Summary
 
Fields inherited from class com.smartgwt.client.rpc.RPCResponse
STATUS_CONNECTION_RESET_ERROR, STATUS_FAILURE, STATUS_LOGIN_INCORRECT, STATUS_LOGIN_REQUIRED, STATUS_LOGIN_SUCCESS, STATUS_MAX_FILE_SIZE_EXCEEDED, STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED, STATUS_OFFLINE, STATUS_SERVER_TIMEOUT, STATUS_SUCCESS, STATUS_TRANSACTION_FAILED, STATUS_TRANSPORT_ERROR, STATUS_UNKNOWN_HOST_ERROR, STATUS_UPDATE_WITHOUT_PK_ERROR, STATUS_VALIDATION_ERROR
 
Fields inherited from class com.smartgwt.client.core.JsObject
jsObj
 
Constructor Summary
DSResponse()
           
DSResponse(JavaScriptObject jsObj)
           
DSResponse(String dataSource)
           
DSResponse(String dataSource, DSOperationType operationType)
           
DSResponse(String dataSource, DSOperationType operationType, Record... data)
           
 
Method Summary
 Record[] getData()
          For "fetch" operations, this is the array of Records fetched.
 RecordList getDataAsRecordList()
          For "fetch" operations, this is the array of Records fetched.
 String getDataSource()
          The DataSource of this DSResponse.
 Integer getEndRow()
          End row of returned server results, when using paged result fetching
 Map getErrors()
          Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user.
 Boolean getFromOfflineCache()
          If set, indicates that this response came from the offline cache, not the server.
 Map getHttpHeaders()
          HTTP headers returned by the server as a map from header name to header value.
 Boolean getInvalidateCache()
          Optional flag that can be set by the server to force ResultSets to drop any caches of records from the DataSource that was the target of the operation.
 Integer getOfflineTimestamp()
          Timestamp (millisecond value) to indicate when this dsResponse was cached in offline storage.
 DSOperationType getOperationType()
          The operation type of the request corresponding to this DSResponse.
static DSResponse getOrCreateRef(JavaScriptObject jsObj)
           
 int getQueueStatus()
          An extra property of each DSResponse to a queued request that indicates whether the queue as a whole succeeded.
 Integer getStartRow()
          Starting row of returned server results, when using paged result fetching
 int getStatus()
          Same meaning as status, except DSResponses have additional error codes, such as validation failure.
 Integer getTotalRows()
          Total number of rows available from the server that match the current filter criteria, when using paged result fetching.
 void setData(Record... data)
          For "fetch" operations, this is the array of Records fetched.
 void setDataSource(String dataSource)
          The DataSource of this DSResponse.
 void setEndRow(Integer endRow)
          End row of returned server results, when using paged result fetching
 void setErrors(JavaScriptObject errors)
          Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user.
 void setErrors(Map errors)
          Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user.
 void setInvalidateCache(Boolean invalidateCache)
          Optional flag that can be set by the server to force ResultSets to drop any caches of records from the DataSource that was the target of the operation.
 void setOperationType(DSOperationType operationType)
          The operation type of the request corresponding to this DSResponse.
 void setQueueStatus(int queueStatus)
          An extra property of each DSResponse to a queued request that indicates whether the queue as a whole succeeded.
 void setStartRow(Integer startRow)
          Starting row of returned server results, when using paged result fetching
 void setStatus(int status)
          Same meaning as status, except DSResponses have additional error codes, such as validation failure.
 void setTotalRows(Integer totalRows)
          Total number of rows available from the server that match the current filter criteria, when using paged result fetching.
 
Methods inherited from class com.smartgwt.client.rpc.RPCResponse
create, getDataAsMap, getDataAsObject, getDataAsString, getHttpResponseCode, getHttpResponseText, getTransactionNum
 
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, 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, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObj
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSResponse

public DSResponse()

DSResponse

public DSResponse(JavaScriptObject jsObj)

DSResponse

public DSResponse(String dataSource)

DSResponse

public DSResponse(String dataSource,
                  DSOperationType operationType)

DSResponse

public DSResponse(String dataSource,
                  DSOperationType operationType,
                  Record... data)
Method Detail

getOrCreateRef

public static DSResponse getOrCreateRef(JavaScriptObject jsObj)

getData

public Record[] getData()
For "fetch" operations, this is the array of Records fetched. For "update", "add", and "remove" operations, this is typically an array containing a single Record representing the record that was updated, added, or removed.

Returns:
Record...

getDataAsRecordList

public RecordList getDataAsRecordList()
For "fetch" operations, this is the array of Records fetched. For "update", "add", and "remove" operations, this is typically an array containing a single Record representing the record that was updated, added, or removed.

Returns:
RecordList

setDataSource

public void setDataSource(String dataSource)
The DataSource of this DSResponse.

Parameters:
dataSource - Default value is null

getDataSource

public String getDataSource()
The DataSource of this DSResponse.

Returns:
String

getEndRow

public Integer getEndRow()
End row of returned server results, when using paged result fetching

Note that startRow and endRow are zero-based - the first record is row zero.

Returns:
Integer

getFromOfflineCache

public Boolean getFromOfflineCache()
If set, indicates that this response came from the offline cache, not the server. This flag is the only reliable way for application code to determine the source of a response.

Returns:
Boolean

getHttpHeaders

public Map getHttpHeaders()
HTTP headers returned by the server as a map from header name to 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.

Overrides:
getHttpHeaders in class RPCResponse
Returns:
Map

getInvalidateCache

public Boolean getInvalidateCache()
Optional flag that can be set by the server to force ResultSets to drop any caches of records from the DataSource that was the target of the operation.

Returns:
Boolean

getOfflineTimestamp

public Integer getOfflineTimestamp()
Timestamp (millisecond value) to indicate when this dsResponse was cached in offline storage. Not applicable if the response has never been stored offline.

Returns:
Integer

setOperationType

public void setOperationType(DSOperationType operationType)
The operation type of the request corresponding to this DSResponse.

Parameters:
operationType - Default value is null

getOperationType

public DSOperationType getOperationType()
The operation type of the request corresponding to this DSResponse.

Returns:
DSOperationType

setQueueStatus

public void setQueueStatus(int queueStatus)
An extra property of each DSResponse to a queued request that indicates whether the queue as a whole succeeded. A queueStatus of STATUS_SUCCESS, or 0, indicates that the queue succeeded whereas a queueStatus of STATUS_FAILURE, or -1, indicates that the queue failed.

For example, if two "update" requests are sent in a queue and the first succeeded, but the second failed validation, then both DSResponses' queueStatus would be -1, but the status of the first would be STATUS_SUCCESS and the status of the second would be an error code such as STATUS_VALIDATION_ERROR.

Parameters:
queueStatus -
See Also:
ErrorHandling overview and related methods

getQueueStatus

public int getQueueStatus()
An extra property of each DSResponse to a queued request that indicates whether the queue as a whole succeeded. A queueStatus of STATUS_SUCCESS, or 0, indicates that the queue succeeded whereas a queueStatus of STATUS_FAILURE, or -1, indicates that the queue failed.

For example, if two "update" requests are sent in a queue and the first succeeded, but the second failed validation, then both DSResponses' queueStatus would be -1, but the status of the first would be STATUS_SUCCESS and the status of the second would be an error code such as STATUS_VALIDATION_ERROR.

Returns:
int
See Also:
ErrorHandling overview and related methods

getStartRow

public Integer getStartRow()
Starting row of returned server results, when using paged result fetching

Note that startRow and endRow are zero-based - the first record is row zero.

Returns:
Integer

setStatus

public void setStatus(int status)
Same meaning as status, except DSResponses have additional error codes, such as validation failure.

Overrides:
setStatus in class RPCResponse
Parameters:
status -
See Also:
ErrorHandling overview and related methods

getStatus

public int getStatus()
Same meaning as status, except DSResponses have additional error codes, such as validation failure.

Overrides:
getStatus in class RPCResponse
Returns:
int
See Also:
ErrorHandling overview and related methods

getTotalRows

public Integer getTotalRows()
Total number of rows available from the server that match the current filter criteria, when using paged result fetching.

Returns:
Integer

setStartRow

public void setStartRow(Integer startRow)
Starting row of returned server results, when using paged result fetching

Note that startRow and endRow are zero-based - the first record is row zero.

Parameters:
startRow - the start row

setEndRow

public void setEndRow(Integer endRow)
End row of returned server results, when using paged result fetching

Note that startRow and endRow are zero-based - the first record is row zero.

Parameters:
endRow - the end row

setTotalRows

public void setTotalRows(Integer totalRows)
Total number of rows available from the server that match the current filter criteria, when using paged result fetching.

Parameters:
totalRows - total rows

setInvalidateCache

public void setInvalidateCache(Boolean invalidateCache)
Optional flag that can be set by the server to force ResultSets to drop any caches of records from the DataSource that was the target of the operation.

Parameters:
invalidateCache - invalidateCache

setErrors

public void setErrors(Map errors)
Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user. For example:
     dsResponse.errors = {         userId : "A user with this userId already exists",
 orderId : "No Order with ID '6A18294' exists"     } 
The Java API DSResponse.addError(fieldName, errorMessage) is used to send server-side errors to the client. See the Java Server Reference for details.

Parameters:
errors - errors map

setErrors

public void setErrors(JavaScriptObject errors)
Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user. For example:
     dsResponse.errors = {         userId : "A user with this userId already exists",
 orderId : "No Order with ID '6A18294' exists"     } 
The Java API DSResponse.addError(fieldName, errorMessage) is used to send server-side errors to the client. See the Java Server Reference for details.

Parameters:
errors - errors as JavaScriptObject

setData

public void setData(Record... data)
For "fetch" operations, this is the array of Records fetched. For "update", "add", and "remove" operations, this is typically an array containing a single Record representing the record that was updated, added, or removed.

Parameters:
data - data Default value is null

getErrors

public Map getErrors()
Server-side validation errors for an attempted "update" or "add" operation, as a JS Object where each property name is a field name from the record and each property value is an error message to be shown to the user. For example:
      {
        userId : ["A user with this userId already exists"],
        orderId : ["Must be a numeric value", "No Order with ID '6A18294' exists"]
      }
 
The Java API DSResponse.addError(fieldName, errorMessage) is used to send server-side errors to the client. See the Java Server Reference for details.

Returns:
the errors map