com.opensymphony.xwork.validator
Class ValidationInterceptor
java.lang.Object
com.opensymphony.xwork.interceptor.AroundInterceptor
com.opensymphony.xwork.validator.ValidationInterceptor
- All Implemented Interfaces:
- Interceptor
public class ValidationInterceptor
- extends AroundInterceptor
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.
This interceptor does nothing if the name of the method being invoked is specified in the excludeMethods
parameter. excludeMethods accepts a comma-delimited list of method names. For example, requests to
foo!input.action and foo!back.action will be skipped by this interceptor if you set the
excludeMethods parameter to "input, back".
Note that this has nothing to do with the Validateable interface and simply adds
error messages to the action. The workflow of the action request does not change due to this interceptor. Rather,
this interceptor is often used in conjuction with the workflow interceptor.
Interceptor parameters:
Extending the interceptor:
There are no known extension points for this interceptor.
Example code:
<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>
- Author:
- Jason Carreira, Rainer Hermanns
- See Also:
ActionValidatorManager,
DefaultWorkflowInterceptor
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ValidationInterceptor
public ValidationInterceptor()
setExcludeMethods
public void setExcludeMethods(String excludeMethods)
after
protected void after(ActionInvocation dispatcher,
String result)
throws Exception
- Description copied from class:
AroundInterceptor
- Called after the invocation has been executed.
- Specified by:
after in class AroundInterceptor
result - the result value returned by the invocation
- Throws:
Exception
before
protected void before(ActionInvocation invocation)
throws Exception
- Gets the current action and its context and calls
ActionValidatorManager.validate(Object, String).
- Specified by:
before in class AroundInterceptor
- Parameters:
invocation - the execution state of the Action.
- Throws:
Exception - if an error occurs validating the action.