|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.webwork.dispatcher.json.JSONResult
public class JSONResult
Attempt to retrieve an instance of JSONObject
from WebWork's ValueStack through property returned from
getJSONObjectProperty()
and write the String representation of the retrived JSONObject
to
HttpServletResponse
's outputstream. Normally having accessor methods for the property in WebWork's action
would do the trick.
JSONObject
. Default to 'jsonObject'.
<action name="getActiveCustomers" class="..."> <result name="success" type="json"> <param name="jsonObjectProperty">activeCustomer</param> <param name="contentType">application/json</param> </result> ... </action>> Or just <action name="getActiveCustomers" class="..."> <result name="success" type="json" /> ... </action> if we used the default property ('jsonObject') and default content-type ('application/json')
Constructor Summary | |
---|---|
JSONResult()
|
Method Summary | |
---|---|
void |
execute(ActionInvocation invocation)
Writes the string representation of JSONObject defined through getJSONObjectProperty()
to HttpServletResponse 's outputstream. |
String |
getContentType()
Returns the content-type header to be used. |
protected JSONObject |
getJSONObject(ActionInvocation invocation)
Attempt to look up a JSONObject instance through the property
(getJSONObjectProperty() ) by looking up the property in WebWork's ValueStack. |
String |
getJSONObjectProperty()
Returns the property which will be used to lookup JSONObject in WebWork's ValueStack. |
protected HttpServletResponse |
getServletResponse(ActionInvocation invocation)
Returns a HttpServletResponse by looking it up through WebWork's ActionContext Map. |
void |
setContentType(String contentType)
Set the content-type header to be used. |
void |
setJSONObjectProperty(String jsonObject)
Set the property which will be used to lookup JSONObject in WebWork's ValueStack. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSONResult()
Method Detail |
---|
public String getJSONObjectProperty()
JSONObject
in WebWork's ValueStack. Default to
'jsonObject'.
public void setJSONObjectProperty(String jsonObject)
JSONObject
in WebWork's ValueStack. Default to
'jsonObject'.
jsonObject
- public String getContentType()
public void setContentType(String contentType)
contentType
- public void execute(ActionInvocation invocation) throws Exception
JSONObject
defined through getJSONObjectProperty()
to HttpServletResponse
's outputstream.
execute
in interface Result
invocation
-
Exception
protected JSONObject getJSONObject(ActionInvocation invocation) throws JSONException
JSONObject
instance through the property
(getJSONObjectProperty()
) by looking up the property in WebWork's ValueStack. It shall be found if there's
accessor method for the property in WebWork's action itself.
Returns null if one cannot be found.
We could override this method to return the desired JSONObject when writing testcases.
invocation
-
JSONObject
or null if one cannot be found
JSONException
protected HttpServletResponse getServletResponse(ActionInvocation invocation)
HttpServletResponse
by looking it up through WebWork's ActionContext Map.
We could override this method to return the desired Mock HttpServletResponse when writing testcases.
invocation
-
HttpServletResponse
|
WebWork Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |