com.opensymphony.xwork.interceptor
Class DefaultWorkflowInterceptor
java.lang.Object
com.opensymphony.xwork.interceptor.MethodFilterInterceptor
com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor
- All Implemented Interfaces:
- Interceptor, Serializable
- public class DefaultWorkflowInterceptor
- extends MethodFilterInterceptor
An interceptor that does some basic validation workflow before allowing the interceptor chain to continue.
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".
The order of execution in the workflow is:
- If the action being executed implements
Validateable
, the action's validate
method is called.
- Next, if the action implements
ValidationAware
, the action's hasErrors
method is called. If this method returns true, this interceptor stops the chain from continuing and
immediately returns Action.INPUT
Note: if the action doesn't implement either interface, this interceptor effectively does nothing. This
interceptor is often used with the validation interceptor. However, it does not have to be, especially if you
wish to write all your validation rules by hand in the validate() method rather than in XML files.
NOTE: As this method extends off MethodFilterInterceptor, it is capable of
deciding if it is applicable only to selective methods in the action class. See
MethodFilterInterceptor
for more info.
Update: Added logic to execute a validate{MethodName} rather than a general validate method.
This allows us to run some validation logic based on the method name we specify in the
ActionProxy. For example, you can specify a validateInput() method, or even a validateDoInput()
method that will be run before the invocation of the input method.
Interceptor parameters:
- alwaysInvokeValidate - Default to true. If true validate() method will always
be invoked, otherwise it will not.
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>
<-- In this case myMethod of the action class will not pass through
the workflow process -->
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="params"/>
<interceptor-ref name="validation"/>
<interceptor-ref name="workflow">
<param name="excludeMethods">myMethod</param>
</interceptor-ref name="workflow">
<result name="success">good_result.ftl</result>
</action>
- Version:
- $Date: 2006-07-13 18:45:58 +0200 (Thu, 13 Jul 2006) $ $Id: DefaultWorkflowInterceptor.java 1070 2006-07-13 18:45:58 +0200 (Thu, 13 Jul 2006) plightbo $
- Author:
- Jason Carreira, Rainer Hermanns, Alexandru Popescu, Philip Luppens, tm_jee
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultWorkflowInterceptor
public DefaultWorkflowInterceptor()
setAlwaysInvokeValidate
public void setAlwaysInvokeValidate(String alwaysInvokeValidate)
doIntercept
protected String doIntercept(ActionInvocation invocation)
throws Exception
- Description copied from class:
MethodFilterInterceptor
- Subclasses must override to implement the interceptor logic.
- Specified by:
doIntercept
in class MethodFilterInterceptor
- Parameters:
invocation
- the action invocation
- Returns:
- the result of invocation
- Throws:
Exception