Class ResourceResponse
java.lang.Object
org.json.JSONObject
com.onenetwork.platform.integ.rest.ResourceResponse
public class ResourceResponse
extends org.json.JSONObject
Resource response object which is specifically useful in the context of
Platform UI components. A common pattern in ext components is to expect
an AJAX response to return a JSON containing one or all of "items", "message"
and "success". This contains convenient getters/setters for each of these.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ResourceResponse()
"success" response with no message.ResourceResponse(java.lang.String message)
"success" response with user-provided message.ResourceResponse(java.lang.String message, boolean success)
Response with user-provided message, where success or failure given as a paramResourceResponse(java.lang.String message, boolean success, org.json.JSONObject data)
LikeJSONObject.accumulate(String, Object)
, but accepts an additional JSONObject whose properties will be "overlayed" on top of this ResourceResponse. -
Method Summary
Modifier and Type Method Description org.json.JSONArray
getItems()
java.lang.String
getMessage()
boolean
isSuccess()
void
setItems(org.json.JSONArray items)
void
setMessage(java.lang.String message)
void
setSuccess(boolean success)
Methods inherited from class org.json.JSONObject
accumulate, append, asMap, doubleToString, entrySet, get, getBigDecimal, getBigInteger, getBoolean, getDouble, getEnum, getFloat, getInt, getJSONArray, getJSONObject, getLong, getNames, getNames, getNumber, getString, has, increment, isDecimalNotation, isEmpty, isNull, keys, keySet, length, names, numberToString, opt, optBigDecimal, optBigInteger, optBoolean, optBoolean, optDouble, optDouble, optEnum, optEnum, optFloat, optFloat, optInt, optInt, optJSONArray, optJSONObject, optLong, optLong, optNumber, optNumber, optQuery, optQuery, optString, optString, put, put, put, put, put, put, put, put, putOnce, putOpt, query, query, quote, quote, remove, similar, stringToNumber, stringToValue, testValidity, toJSONArray, toMap, toString, toString, valueToString, wrap, write, write
-
Constructor Details
-
ResourceResponse
public ResourceResponse()"success" response with no message. -
ResourceResponse
public ResourceResponse(java.lang.String message)"success" response with user-provided message. -
ResourceResponse
public ResourceResponse(java.lang.String message, boolean success)Response with user-provided message, where success or failure given as a param -
ResourceResponse
public ResourceResponse(java.lang.String message, boolean success, org.json.JSONObject data)LikeJSONObject.accumulate(String, Object)
, but accepts an additional JSONObject whose properties will be "overlayed" on top of this ResourceResponse. Thus if you give a JSONObject with a property of "foo", the ResourceResponse itself will have the same property.
-
-
Method Details
-
getMessage
public java.lang.String getMessage() -
setMessage
public void setMessage(java.lang.String message) -
isSuccess
public boolean isSuccess() -
setSuccess
public void setSuccess(boolean success) -
getItems
public org.json.JSONArray getItems() -
setItems
public void setItems(org.json.JSONArray items)- Parameters:
items
- the items to set
-