|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.json.JSONResult
public class JSONResult
This result serializes an action into JSON. Result parameters:
<!-- START SNIPPET: example --> <result name="success" type="json" /> <!-- END SNIPPET: example -->
Constructor Summary | |
---|---|
JSONResult()
|
Method Summary | |
---|---|
protected java.lang.String |
addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request,
java.lang.String json)
|
protected SMD |
buildSMDObject(ActionInvocation invocation)
|
void |
execute(ActionInvocation invocation)
|
java.lang.String |
getCallbackParameter()
|
protected java.lang.String |
getEncoding()
Retrieve the encoding |
java.util.List<java.util.regex.Pattern> |
getExcludePropertiesList()
Gets a list of regular expressions of properties to exclude from the JSON output. |
java.util.List<java.util.regex.Pattern> |
getIncludePropertiesList()
|
java.lang.String |
getRoot()
|
java.lang.String |
getWrapPrefix()
|
java.lang.String |
getWrapSuffix()
|
boolean |
isEnableGZIP()
|
boolean |
isEnableSMD()
|
boolean |
isEnumAsBean()
|
boolean |
isExcludeNullProperties()
|
boolean |
isIgnoreHierarchy()
|
boolean |
isNoCache()
|
boolean |
isWrapWithComments()
|
void |
setCallbackParameter(java.lang.String callbackParameter)
|
void |
setContentType(java.lang.String contentType)
Content type to be set in the response |
void |
setDefaultEncoding(java.lang.String val)
|
void |
setEnableGZIP(boolean enableGZIP)
|
void |
setEnableSMD(boolean enableSMD)
Enable SMD generation for action, which can be used for JSON-RPC |
void |
setEnumAsBean(boolean enumAsBean)
Controls how Enum's are serialized : If true, an Enum is serialized as a name=value pair (name=name()) (default) If false, an Enum is serialized as a bean with a special property _name=name() |
void |
setErrorCode(int errorCode)
Error code to be set in the response |
void |
setExcludeNullProperties(boolean excludeNullProperties)
Do not serialize properties with a null value |
void |
setExcludeProperties(java.lang.String commaDelim)
Sets a comma-delimited list of regular expressions to match properties that should be excluded from the JSON output. |
void |
setExcludeWildcards(java.lang.String commaDelim)
Sets a comma-delimited list of wildcard expressions to match properties that should be excluded from the JSON output. |
void |
setIgnoreHierarchy(boolean ignoreHierarchy)
|
void |
setIgnoreInterfaces(boolean ignoreInterfaces)
Controls whether interfaces should be inspected for method annotations You may need to set to this true if your action is a proxy as annotations on methods are not inherited |
void |
setIncludeProperties(java.lang.String commaDelim)
Sets a comma-delimited list of regular expressions to match properties that should be included in the JSON output. |
void |
setIncludeWildcards(java.lang.String commaDelim)
Sets a comma-delimited list of wildcard expressions to match properties that should be included in the JSON output. |
void |
setNoCache(boolean noCache)
Add headers to response to prevent the browser from caching the response |
void |
setPrefix(boolean prefix)
Prefix JSON with "{} &&" |
void |
setRoot(java.lang.String root)
Sets the root object to be serialized, defaults to the Action |
void |
setStatusCode(int statusCode)
Status code to be set in the response |
void |
setWrapPrefix(java.lang.String wrapPrefix)
Text to be inserted at the begining of the response |
void |
setWrapSuffix(java.lang.String wrapSuffix)
Text to be inserted at the end of the response |
void |
setWrapWithComments(boolean wrapWithComments)
Wrap generated JSON with comments |
protected void |
writeToResponse(javax.servlet.http.HttpServletResponse response,
java.lang.String json,
boolean gzip)
|
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 void setDefaultEncoding(java.lang.String val)
public java.util.List<java.util.regex.Pattern> getExcludePropertiesList()
public void setExcludeProperties(java.lang.String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setExcludeWildcards(java.lang.String commaDelim)
commaDelim
- A comma-delimited list of wildcard patternspublic java.util.List<java.util.regex.Pattern> getIncludePropertiesList()
public void setIncludeProperties(java.lang.String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setIncludeWildcards(java.lang.String commaDelim)
commaDelim
- A comma-delimited list of wildcard patternspublic void execute(ActionInvocation invocation) throws java.lang.Exception
execute
in interface Result
java.lang.Exception
protected void writeToResponse(javax.servlet.http.HttpServletResponse response, java.lang.String json, boolean gzip) throws java.io.IOException
java.io.IOException
protected SMD buildSMDObject(ActionInvocation invocation)
protected java.lang.String getEncoding()
protected java.lang.String addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request, java.lang.String json)
public java.lang.String getRoot()
public void setRoot(java.lang.String root)
root
- OGNL expression of root object to be serializedpublic boolean isWrapWithComments()
public void setWrapWithComments(boolean wrapWithComments)
wrapWithComments
- public boolean isEnableSMD()
public void setEnableSMD(boolean enableSMD)
enableSMD
- public void setIgnoreHierarchy(boolean ignoreHierarchy)
public void setIgnoreInterfaces(boolean ignoreInterfaces)
public void setEnumAsBean(boolean enumAsBean)
enumAsBean
- public boolean isEnumAsBean()
public boolean isEnableGZIP()
public void setEnableGZIP(boolean enableGZIP)
public boolean isNoCache()
public void setNoCache(boolean noCache)
noCache
- public boolean isIgnoreHierarchy()
public boolean isExcludeNullProperties()
public void setExcludeNullProperties(boolean excludeNullProperties)
excludeNullProperties
- public void setStatusCode(int statusCode)
statusCode
- public void setErrorCode(int errorCode)
errorCode
- public void setCallbackParameter(java.lang.String callbackParameter)
public java.lang.String getCallbackParameter()
public void setPrefix(boolean prefix)
prefix
- public void setContentType(java.lang.String contentType)
contentType
- public java.lang.String getWrapPrefix()
public void setWrapPrefix(java.lang.String wrapPrefix)
public java.lang.String getWrapSuffix()
public void setWrapSuffix(java.lang.String wrapSuffix)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |