Package ubic.gemma.web.remote
Class JsonReaderResponse<T>
- java.lang.Object
-
- ubic.gemma.web.remote.JsonReaderResponse<T>
-
- Type Parameters:
T
- Type of Objects that will be converted to Ext.data.Records by the client-side Ext.data.DataReader.
public class JsonReaderResponse<T> extends Object
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 http://github.com/BigLep/ExtJsWithDwr/)
-
-
Field Summary
Fields Modifier and Type Field Description String
message
Collection<T>
records
boolean
success
long
totalRecords
-
Constructor Summary
Constructors Constructor Description JsonReaderResponse(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getMessage()
Collection<T>
getRecords()
long
getTotalRecords()
boolean
isSuccess()
void
setMessage(String message)
void
setRecords(List<T> records)
void
setSuccess(boolean success)
void
setTotalRecords(long totalRecords)
-
-
-
Field Detail
-
message
public String message
-
records
public Collection<T> records
-
success
public boolean success
-
totalRecords
public long totalRecords
-
-
Constructor Detail
-
JsonReaderResponse
public JsonReaderResponse(List<T> objectsToConvertToRecords)
Creates a successful JsonReaderResponse with the provided objectsToConvertToRecords. The totalRecords is assumed to be the length of objectsToConvertToRecords
-
JsonReaderResponse
public JsonReaderResponse(Collection<T> objectsToConvertToRecords, long totalRecords)
Use for remote paging applications. Creates asuccess
ful JsonReaderResponse with the provided objectsToConvertToRecords.- Parameters:
objectsToConvertToRecords
- objects to converttotalRecords
- total records
-
JsonReaderResponse
public JsonReaderResponse(String message)
Creates an unsuccess
ful 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 Detail
-
getMessage
public String getMessage()
- Returns:
- the message
-
setMessage
public void setMessage(String message)
- Parameters:
message
- the message to set
-
getRecords
public Collection<T> getRecords()
- Returns:
- the records
-
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
-
-