|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.isomorphic.datasource.DSResponse
| Field Summary | |
static int |
STATUS_FAILURE
Indicates a failure of some sort (generic). |
static int |
STATUS_SUCCESS
Indicates successful completion of the request. |
static int |
STATUS_VALIDATION_ERROR
This error code indicates a validation failure. |
| Constructor Summary | |
DSResponse()
Creates an empty DSResponse. |
|
DSResponse(int status)
Creates a DSResponse with the specified status code. |
|
DSResponse(java.lang.Object data)
Creates a DSResponse with the specified status code. |
|
DSResponse(java.lang.Object data,
int status)
Creates a DSResponse with the specified data payload and status code. |
|
| Method Summary | |
void |
addError(java.lang.String fieldName,
ErrorMessage errorMessage)
Adds an ErrorMessage to the ErrorReport for this DSResponse. |
void |
addError(java.lang.String fieldName,
java.lang.String errorMessage)
Adds an ErrorMessage to the ErrorReport for this DSResponse. |
long |
getAffectedRows()
For operations that modify data, this method returns the number of rows affected by the change. |
java.lang.Object |
getData()
Returns the data object originally set by setData() |
long |
getEndRow()
Returns the endRow for this DSResponse. |
ErrorReport |
getErrorReport()
Returns the current ErrorReport. |
boolean |
getInvalidateCache()
Returns the current value of invalidateCache |
long |
getStartRow()
Returns the startRow for this DSResponse. |
int |
getStatus()
Returns the currently set status code. |
long |
getTotalRows()
Returns the totalRows for this DSResponse. |
void |
setData(java.lang.Object data)
Sets the data to satisfy the DataSource request. |
void |
setEndRow(long endRow)
If the DSRequest specified an endRow, then the DSResponse should return the actual endRow for the response. |
void |
setErrorReport(ErrorReport errorReport)
Sets the ErrorReport for this DSResponse |
void |
setFailure()
Sets the status code to STATUS_FAILURE |
void |
setInvalidateCache(boolean invalidateCache)
Setting invalidateCache to true triggers the client-side ResultSet to drop its existing cache. |
void |
setStartRow(long startRow)
If the DSRequest specified a startRow, then the DSResponse should return the actual startRow for the response. |
void |
setStatus(int status)
Sets the status of this DSResponse. |
void |
setSuccess()
Sets the status of this DSResponse to STATUS_SUCCESS. |
void |
setTotalRows(long totalRows)
If the DSRequest sent a paged request (see DSRequest.isPaged()) and the total number of records available to be sent to the client given the provided criteria is greater than the requested size, then you should provide the total number of rows that actually matched the provided criteria. |
boolean |
statusIsError()
Returns true unless the currently status is STATUS_SUCCESS |
boolean |
statusIsSuccess()
|
| Field Detail |
public static final int STATUS_SUCCESS
public static final int STATUS_FAILURE
See also the error handling doc section in RPCManager for information on how the client handles errors.
public static final int STATUS_VALIDATION_ERROR
This error code will automatically be set for you if you call setErrors() or addError().
| Constructor Detail |
public DSResponse()
public DSResponse(int status)
status - the status code (one of the static STATUS_* codes on this class)public DSResponse(java.lang.Object data)
data - the payload of the response - equivalent to setData()
public DSResponse(java.lang.Object data,
int status)
data - the payload of the response - equivalent to setData()status - the status code (one of the static STATUS_* codes on this class)| Method Detail |
public long getAffectedRows()
public boolean getInvalidateCache()
public void setInvalidateCache(boolean invalidateCache)
invalidateCache - new value for invalidateCachepublic void setData(java.lang.Object data)
The object passed to setData() is translated to JavaScript via the JSTranslater class. The expected return data varies by operationType and is described in terms of the JavaScript result (see below) - anything that will be translated to the appropriate JavaScript result is acceptable. Compare all the data formats you can readily retrieve against the capabilities of the JSTranslater. Common options are to pass an XML document fragment or a Collection of Java Beans.
If the operationType is DataSource.OP_FETCH, then the data is expected to be an Array of JavaScript Objects matching the criteria specified in the DSRequest.
If the operationType is DataSource.OP_UPDATE, then the data is expected to be a JavaScript Object reflecting the updated record as stored.
If the operationType is DataSource.OP_ADD, then the data is expected to be a JavaScript Object reflecting the added record as stored.
If the operationType is DataSource.OP_REMOVE, then the data is expected to be at least the primary key fields of the removed record, an as JavaScript Object. A complete record is also acceptable.
DSResponses or DSResponse data returned by DMI methods is, by default, automatically
filtered to just the set of fields defined on the DataSource. You can override this
default in several ways - see the DMI overview in the SmartClient Reference
documentation for a full description. For backwards compatibility, non-DMI DSResponses
are not filtered in this manner. If you want to enable this filtering for non-DMI
responses, you can do so by setting the config parameter
DSResponse.dropExtraFields to true in
[webroot]/WEB-INF/classes/server.properties. Note that per-DataSource
overrides specified by the dropExtraFields setting on the DataSource will
still apply in this case. Note that DMI.dropExtraFields
and DSResponse.dropExtraFields can be enabled/disabled independently of each
other - that is, setting one does not side-effect the other.
data - the dataJSTranslater.toJS(Object, Writer),
JSONFilterpublic java.lang.Object getData()
setData(Object)public long getStartRow()
public void setStartRow(long startRow)
Note that startRow and endRow are zero-based - the first record is row zero.
startRow - new value for startRowpublic long getEndRow()
public void setEndRow(long endRow)
Note that startRow and endRow are zero-based - the first record is row zero.
If startRow is currently greater than endRow, it will be
reduced to a maximum of endRow-1 (or 0).
endRow - new value for endRowpublic long getTotalRows()
public void setTotalRows(long totalRows)
For example, the ListGrid uses this value to display a properly sized scrollbar thumb.
DSRequest.isPaged()public int getStatus()
public boolean statusIsError()
public boolean statusIsSuccess()
public void setStatus(int status)
status - new status codepublic void setSuccess()
public void setFailure()
public ErrorReport getErrorReport()
ErrorReport,
ErrorMessage,
DSRequest.validate()public void setErrorReport(ErrorReport errorReport)
errorReport - new errorReport
public void addError(java.lang.String fieldName,
ErrorMessage errorMessage)
fieldName - the fieldName for the errorerrorMessage - the errorMessage
public void addError(java.lang.String fieldName,
java.lang.String errorMessage)
fieldName - the fieldName for the errorerrorMessage - the errorMessage
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||