Package org.apache.struts2.interceptor

# Class DefaultWorkflowInterceptor

java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.MethodFilterInterceptor
org.apache.struts2.interceptor.DefaultWorkflowInterceptor

All Implemented Interfaces:
  `Serializable`, `ConditionalInterceptor`, `Interceptor`

public class DefaultWorkflowInterceptor extends MethodFilterInterceptor

An interceptor that makes sure there are not validation, conversion or action errors before allowing the interceptor chain to continue. If a single FieldError or ActionError (including the ones replicated by the Message Store Interceptor in a redirection) is found, the INPUT result will be triggered. This interceptor does not perform any validation.

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: As this method extends off MethodFilterInterceptor, it is capable of deciding if it is applicable only to selective methods in the action class. This is done by adding param tags for the interceptor element, naming either a list of excluded method names and/or a list of included method names, whereby includeMethods overrides excludedMethods. A single * sign is interpreted as wildcard matching all methods for both parameters. See `MethodFilterInterceptor` for more info.

This interceptor also supports the following interfaces which can implemented by actions:

- ValidationAware - implemented by ActionSupport class
- ValidationWorkflowAware - allows changing result name programmatically
- ValidationErrorAware - notifies action about errors and also allow change result name

You can also use InputConfig annotation to change result name returned when validation errors occurred.

Interceptor parameters:

- 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 as well as mySecondMethod 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,mySecondMethod</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 -->
     <-- The Interceptor will only be applied for myWorkflowMethod method of action
            classes, since this is the only included method while any others are excluded -->
     <action name="someAction" class="com.examples.SomeAction">
         <interceptor-ref name="params"/>
         <interceptor-ref name="validation"/>
         <interceptor-ref name="workflow">
            <param name="inputResultName">error</param>
             <param name="excludeMethods">*</param>
             <param name="includeMethods">myWorkflowMethod</param>
         </interceptor-ref>
         <result name="success">good_result.ftl</result>
     </action>

Author:
  Jason Carreira, Rainer Hermanns, Alexandru Popescu, Philip Luppens, tm_jee
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class org.apache.struts2.interceptor.MethodFilterInterceptor

  `excludeMethods, includeMethods`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultWorkflowInterceptor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected String`
  `doIntercept(ActionInvocation invocation)`
  Intercept `ActionInvocation` and returns a `inputResultName` when action / field errors is found registered.
  `protected String`
  `processInputConfig(Object action, String method, String currentResultName)`
  Process `InputConfig` annotation applied to method
  `protected String`
  `processValidationErrorAware(Object action, String currentResultName)`
  Notify action if it implements `ValidationErrorAware` interface
  `void`
  `setInputResultName(String inputResultName)`
  Set the `inputResultName` (result name to be returned when a action / field error is found registered).

  ### Methods inherited from class org.apache.struts2.interceptor.MethodFilterInterceptor

  `applyInterceptor, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethods`

  ### Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor

  `destroy, init, setDisabled, shouldIntercept`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DefaultWorkflowInterceptor

    public DefaultWorkflowInterceptor()

- ## Method Details

  - ### 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` - what result name to use when there was validation error(s).

  - ### 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` - in case of any errors

  - ### processInputConfig

    protected String processInputConfig(Object action, String method, String currentResultName) throws Exception
    Process `InputConfig` annotation applied to method
    Parameters:
      `action` - action object
      `method` - method
      `currentResultName` - current result name
    Returns:
      result name
    Throws:
      `Exception` - in case of any errors

  - ### processValidationErrorAware

    protected String processValidationErrorAware(Object action, String currentResultName)
    Notify action if it implements `ValidationErrorAware` interface
    Parameters:
      `action` - action object
      `currentResultName` - current result name
    Returns:
      result name
    See Also:
      - `ValidationErrorAware`