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.validator
Class ValidationInterceptor

    java.lang.Object
      com.opensymphony.xwork2.interceptor.AbstractInterceptor
          com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
              com.opensymphony.xwork2.validator.ValidationInterceptor

All Implemented Interfaces:
  Interceptor, Serializable

    public class ValidationInterceptor

extends MethodFilterInterceptor

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.

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.

Interceptor parameters:

- None

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 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>

Version:
  $Date: 2006-07-10 02:30:29 +0200 (Mon, 10 Jul 2006) $ $Id: ValidationInterceptor.java 1063 2006-07-10 00:30:29Z mrdon $
Author:
  Jason Carreira, Rainer Hermanns, Alexandru Popescu
See Also:
  `ActionValidatorManager`, `DefaultWorkflowInterceptor`, Serialized Form

Field Summary

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 calls `DefaultActionValidatorManager.validate(Object, String)`.
`protected String` | `doIntercept(ActionInvocation invocation)` Subclasses must override to implement the interceptor logic.

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`

Constructor Detail

### ValidationInterceptor

    public ValidationInterceptor()

Method Detail

### doBeforeInvocation

    protected void doBeforeInvocation(ActionInvocation invocation)
                               throws Exception

  Gets the current action and its context and calls `DefaultActionValidatorManager.validate(Object, String)`.

  Parameters:
    `invocation` - the execution state of the Action.
  Throws:
    `Exception` - if an error occurs validating the action.

### 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`

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 © 2007 OpenSymphony. All Rights Reserved.