opensubscriber
   Find in this group all groups
 
Unknown more information…

d : dev@struts.apache.org 1 September 2009 • 1:33AM -0400

Re: Interceptor proposal: BeforeValidationInterceptor
by Alex Siman

REPLY TO AUTHOR
 
REPLY TO GROUP





Sorry, I forgot about
"com.opensymphony.xwork2.interceptor.PrepareInterceptor".


Alex Siman wrote:
>
> 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-tp25226884p25227304.html
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@stru...
For additional commands, e-mail: dev-help@stru...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.