|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
org.apache.struts2.interceptor.validation.JSONValidationInterceptor
public class JSONValidationInterceptor
Serializes validation and action errors into JSON. This interceptor does not perform any validation, so it must follow the 'validation' interceptor on the stack.
This stack (defined in struts-default.xml) shows how to use this interceptor with the 'validation' interceptor
<interceptor-stack name="jsonValidationWorkflowStack"> <interceptor-ref name="basicStack"/> <interceptor-ref name="validation"> <param name="excludeMethods">input,back,cancel</param> </interceptor-ref> <interceptor-ref name="jsonValidation"/> <interceptor-ref name="workflow"/> </interceptor-stack>
If 'validationFailedStatus' is set it will be used as the Response status when validation fails.
If the request has a parameter 'struts.validateOnly' execution will return after validation (action won't be executed).
A request parameter named 'enableJSONValidation' must be set to 'true' to use this interceptor
Field Summary | |
---|---|
(package private) static char[] |
hex
|
private static Logger |
LOG
|
private static String |
VALIDATE_JSON_PARAM
|
private static String |
VALIDATE_ONLY_PARAM
|
private int |
validationFailedStatus
|
Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor |
---|
excludeMethods, includeMethods, log |
Constructor Summary | |
---|---|
JSONValidationInterceptor()
|
Method Summary | |
---|---|
private String |
buildArray(Collection<String> values)
|
protected String |
buildResponse(ValidationAware validationAware)
|
protected String |
doIntercept(ActionInvocation invocation)
Subclasses must override to implement the interceptor logic. |
private String |
escapeJSON(Object obj)
|
void |
setValidationFailedStatus(int validationFailedStatus)
HTTP status that will be set in the response if validation fails |
private String |
unicode(char c)
Represent as unicode |
Methods inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor |
---|
applyInterceptor, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethods |
Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor |
---|
destroy, init |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger LOG
private static final String VALIDATE_ONLY_PARAM
private static final String VALIDATE_JSON_PARAM
static char[] hex
private int validationFailedStatus
Constructor Detail |
---|
public JSONValidationInterceptor()
Method Detail |
---|
public void setValidationFailedStatus(int validationFailedStatus)
validationFailedStatus
- protected String doIntercept(ActionInvocation invocation) throws Exception
MethodFilterInterceptor
doIntercept
in class MethodFilterInterceptor
invocation
- the action invocation
Exception
protected String buildResponse(ValidationAware validationAware)
private String buildArray(Collection<String> values)
private String escapeJSON(Object obj)
private String unicode(char c)
c
- character to be encoded
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |