|
||||||||||
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
com.opensymphony.xwork2.validator.ValidationInterceptor
public class ValidationInterceptor
This interceptor runs the action through the standard validation framework, which in turn checks the action against
any validation rules (found in files such as ActionClass-validation.xml) and adds field-level and action-level
error messages (provided that the action implements ValidationAware
). This interceptor
is often one of the last (or second to last) interceptors applied in a stack, as it assumes that all values have
already been set on the action.
MethodFilterInterceptor
for more info.
Interceptor parameters:
<action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="params"/> <interceptor-ref name="validation"/> <interceptor-ref name="workflow"/> <result name="success">good_result.ftl</result> </action> <-- in the following case myMethod of the action class will not get validated --> <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="params"/> <interceptor-ref name="validation"> <param name="excludeMethods">myMethod</param> </interceptor-ref> <interceptor-ref name="workflow"/> <result name="success">good_result.ftl</result> </action> <-- in the following case only annotated methods of the action class will be validated --> <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="params"/> <interceptor-ref name="validation"> <param name="validateAnnotatedMethodOnly">true</param> </interceptor-ref> <interceptor-ref name="workflow"/> <result name="success">good_result.ftl</result> </action>
ActionValidatorManager
,
DefaultWorkflowInterceptor
,
Serialized FormField Summary | |
---|---|
private ActionValidatorManager |
actionValidatorManager
|
private static String |
ALT_VALIDATE_PREFIX
|
private boolean |
alwaysInvokeValidate
|
private boolean |
declarative
|
private static Logger |
LOG
|
private boolean |
programmatic
|
private static String |
VALIDATE_PREFIX
|
private boolean |
validateAnnotatedMethodOnly
|
Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor |
---|
excludeMethods, includeMethods, log |
Constructor Summary | |
---|---|
ValidationInterceptor()
|
Method Summary | |
---|---|
protected void |
doBeforeInvocation(ActionInvocation invocation)
Gets the current action and its context and delegates to ActionValidatorManager proper validate method. |
protected String |
doIntercept(ActionInvocation invocation)
Subclasses must override to implement the interceptor logic. |
boolean |
isValidateAnnotatedMethodOnly()
Gets if validate() should always be called or only per annotated method. |
void |
setActionValidatorManager(ActionValidatorManager mgr)
|
void |
setAlwaysInvokeValidate(String alwaysInvokeValidate)
Determines if Validateable 's validate() should always
be invoked. |
void |
setDeclarative(boolean declarative)
Determines if validation based on annotations or xml should be performed. |
void |
setProgrammatic(boolean programmatic)
Determines if Validateable 's validate() should be called,
as well as methods whose name that start with "validate". |
void |
setValidateAnnotatedMethodOnly(boolean validateAnnotatedMethodOnly)
Determine if validate() should always be called or only per annotated method. |
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 boolean validateAnnotatedMethodOnly
private ActionValidatorManager actionValidatorManager
private static final Logger LOG
private static final String VALIDATE_PREFIX
private static final String ALT_VALIDATE_PREFIX
private boolean alwaysInvokeValidate
private boolean programmatic
private boolean declarative
Constructor Detail |
---|
public ValidationInterceptor()
Method Detail |
---|
public void setActionValidatorManager(ActionValidatorManager mgr)
public void setProgrammatic(boolean programmatic)
Validateable
's validate()
should be called,
as well as methods whose name that start with "validate". Defaults to "true".
programmatic
- true then validate()
is invoked.public void setDeclarative(boolean declarative)
declarative
- true then perform validation based on annotations or xml.public void setAlwaysInvokeValidate(String alwaysInvokeValidate)
Validateable
's validate()
should always
be invoked. Default to "true".
alwaysInvokeValidate
- true then validate()
is always invoked.public boolean isValidateAnnotatedMethodOnly()
validate()
should always be called or only per annotated method.
public void setValidateAnnotatedMethodOnly(boolean validateAnnotatedMethodOnly)
validate()
should always be called or only per annotated method.
Default to false.
validateAnnotatedMethodOnly
- true to only validate per annotated method, otherwise false to always validate.protected void doBeforeInvocation(ActionInvocation invocation) throws Exception
ActionValidatorManager
proper validate method.
invocation
- the execution state of the Action.
Exception
- if an error occurs validating the action.protected String doIntercept(ActionInvocation invocation) throws Exception
MethodFilterInterceptor
doIntercept
in class MethodFilterInterceptor
invocation
- the action invocation
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |