Class JsonReaderResponse<T>
java.lang.Object
ubic.gemma.web.controller.util.view.JsonReaderResponse<T>
- Type Parameters:
T- Type of Objects that will be converted to Ext.data.Records by the client-side Ext.data.DataReader.
Creates a response that can be consumed by an Ext.data.JsonReader. The client-side Ext.data.JsonReader must have the
"root" property set to "records". Note: Ext documentation often uses "rows" for this property, but "records" is more
clear. Example Ext.data.JsonReader configuration:
{
root : 'records',
successProperty : 'success', // same as default.
messageProperty : 'message',
totalProperty : 'totalRecords'
}
If the parameterized type has two properties "field1" and "field2", then when an instance of this class is read by
the client and there are 100 records in total to page through, it will look like:
{
records : [
{
field1 : 'value',
field2 : 'value',
}, {
field1 : 'value',
field2 : 'value',
}
],
success : true,
totalRecords : 100, // Only needed if you are paging.
message : "Yay!" // optional.
}
Note that for Gemma, 'success' is rarely all that useful because even though DWR will always (?) return a 200, the
error handler gets called.- Author:
- paul (based on BigLep/ExtJsWithDwr)
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanlong -
Constructor Summary
ConstructorsConstructorDescriptionJsonReaderResponse(String message) JsonReaderResponse(Collection<T> objectsToConvertToRecords, long totalRecords) Use for remote paging applications.JsonReaderResponse(List<T> objectsToConvertToRecords) Creates a successful JsonReaderResponse with the provided objectsToConvertToRecords. -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanvoidsetMessage(String message) voidsetRecords(List<T> records) voidsetSuccess(boolean success) voidsetTotalRecords(long totalRecords)
-
Field Details
-
message
-
records
-
success
public boolean success -
totalRecords
public long totalRecords
-
-
Constructor Details
-
JsonReaderResponse
Creates a successful JsonReaderResponse with the provided objectsToConvertToRecords. The totalRecords is assumed to be the length of objectsToConvertToRecords -
JsonReaderResponse
Use for remote paging applications. Creates asuccessful JsonReaderResponse with the provided objectsToConvertToRecords.- Parameters:
objectsToConvertToRecords- objects to converttotalRecords- total records
-
JsonReaderResponse
Creates an unsuccessful JsonReaderResponse with nullrecords. This signals the case where the client established a connection with the server, but the server couldn't fulfill it (e.g., user doesn't have proper user credentials).- Parameters:
message- an error message to give to the client.
-
-
Method Details
-
getMessage
- Returns:
- the message
-
setMessage
- Parameters:
message- the message to set
-
getRecords
- Returns:
- the records
-
setRecords
- Parameters:
records- the records to set
-
getTotalRecords
public long getTotalRecords()- Returns:
- the totalRecords
-
setTotalRecords
public void setTotalRecords(long totalRecords) - Parameters:
totalRecords- the totalRecords to set
-
isSuccess
public boolean isSuccess()- Returns:
- the success
-
setSuccess
public void setSuccess(boolean success) - Parameters:
success- the success to set
-