Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.interceptor
Class DefaultWorkflowInterceptor

    java.lang.Object
      com.opensymphony.xwork2.interceptor.AbstractInterceptor
          com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
              com.opensymphony.xwork2.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:

1. If the action being executed implements `Validateable`, the action's `validate` method is called.
2. 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} and then conditionally followed than a general validate method, depending on the 'alwaysInvokeValidate' parameter/property which is by default set to true. 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 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.
- inputResultName - Default to "input". Determine the result name to be returned when an action / field error is found.

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>

     <-- In this case, the result named "error" will be used when
            an action / field error is found -->
     <action name="someAction" class="com.examples.SomeAction">
         <interceptor-ref name="params"/>
         <interceptor-ref name="validation"/>
         <interceptor-ref name="workflow">
            <param name="inputResultName">error</param>
         </interceptor-ref>
         <result name="success">good_result.ftl</result>
     </action>

Version:
  $Date: 2006-11-12 08:32:00 +0100 (So, 12 Nov 2006) $ $Id: DefaultWorkflowInterceptor.java 1185 2006-11-12 07:32:00Z tm_jee $
Author:
  Jason Carreira, Rainer Hermanns, Alexandru Popescu, Philip Luppens, tm_jee
See Also:
  Serialized Form

Field Summary
`private static Log` | `_log`
`private static String` | `ALT_VALIDATE_PREFIX`
`private boolean` | `alwaysInvokeValidate`
`private String` | `inputResultName`
`private static long` | `serialVersionUID`
`private static String` | `VALIDATE_PREFIX`

Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
`excludeMethods, includeMethods, log`

Constructor Summary
`DefaultWorkflowInterceptor()`

Method Summary
`protected String` | `doIntercept(ActionInvocation invocation)` Intercept `ActionInvocation` and returns a `inputResultName` when action / field errors is found registered.
`void` | `setAlwaysInvokeValidate(String alwaysInvokeValidate)` Determine if `Validateable`'s `validate()` should always be invoked.
`void` | `setInputResultName(String inputResultName)` Set the `inputResultName` (result name to be returned when a action / field error is found registered).

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

### serialVersionUID

    private static final long serialVersionUID

See Also:
  Constant Field Values

### _log

    private static final Log _log

### VALIDATE_PREFIX

    private static final String VALIDATE_PREFIX

See Also:
  Constant Field Values

### ALT_VALIDATE_PREFIX

    private static final String ALT_VALIDATE_PREFIX

See Also:
  Constant Field Values

### alwaysInvokeValidate

    private boolean alwaysInvokeValidate

### inputResultName

    private String inputResultName

Constructor Detail

### DefaultWorkflowInterceptor

    public DefaultWorkflowInterceptor()

Method Detail

### setAlwaysInvokeValidate

    public void setAlwaysInvokeValidate(String alwaysInvokeValidate)

  Determine if `Validateable`'s `validate()` should always be invoked. Default to "true".

  Parameters:
    `alwaysInvokeValidate` -

### setInputResultName

    public void setInputResultName(String inputResultName)

  Set the `inputResultName` (result name to be returned when a action / field error is found registered). Default to `Action.INPUT`

  Parameters:
    `inputResultName` -

### doIntercept

    protected String doIntercept(ActionInvocation invocation)
                          throws Exception

  Intercept `ActionInvocation` and returns a `inputResultName` when action / field errors is found registered.

  Specified by:
    `doIntercept` in class `MethodFilterInterceptor`
  Parameters:
    `invocation` - the action invocation
  Returns:
    String result name
  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.