In my project I use the following simple but logically useful interceptor.
Maybe Struts community will found its useful too.

BeforeValidationInterceptor.java
--------------------------------
/**
 * This interceptor calls {...@link BeforeValidationAware#doBeforeValidation()}
 * on actions which implement {...@link BeforeValidationAware}. This
interceptor
 * is very useful for any situation, where you need to clean up or modify
some
 * parameters just after all parameters are set but before validation and
 * action method invoked.
 *
 * @see BeforeValidationAware
 *
 * @author Alex Siman
 */
@SuppressWarnings("serial")
public class BeforeValidationInterceptor extends AbstractInterceptor
{
        @Override
        public String intercept(ActionInvocation actionInvocation) throws 
Exception
        {
                Object action = actionInvocation.getAction();
                if (action instanceof BeforeValidationAware)
                {
                        ((BeforeValidationAware) action).doBeforeValidation();
                }

                return actionInvocation.invoke();
        }
}


BeforeValidationAware.java
--------------------------------
/**
 * @see BeforeValidationInterceptor
 *
 * @author Alex Siman
 */
public interface BeforeValidationAware
{
        public void doBeforeValidation();
}


struts.xml
--------------------------------
<!-- ... -->
        <interceptor-stack name="beforeValidationStack">
                <!-- ... -->
                <interceptor-ref name="params">
                        dojo\..*,^struts\..*
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="beforeValidation"/>
                <interceptor-ref name="validation">
                        input,back,cancel
                </interceptor-ref>
                <!-- ... -->
        </interceptor-stack>
<!-- ... -->
-- 
View this message in context: 
http://www.nabble.com/Interceptor-proposal%3A-BeforeValidationInterceptor-tp25226884p25226884.html
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org

Reply via email to