You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Bliznak <bl...@rogers.com> on 2009/06/21 00:58:24 UTC
Custom validation interceptor
Hi,
I have following requirement:
If validation of the page fails 3 times in row - invalidate session and redirect to index page.
Should I replace default validation interceptor in default stack with my own to achieve what I am after?
I there any other way?
Any hint would be greatly appreciated
Peter.
Re: Custom validation interceptor
Posted by Peter Bliznak <bl...@rogers.com>.
Preciously!..what you said about changing form is exactly what I was thinking.
________________________________
From: Dave Newton <ne...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Saturday, June 20, 2009 8:35:50 PM
Subject: Re: Custom validation interceptor
Peter Bliznak wrote:
> It is across entire app (there are many dozen of actions) - every
> single action has to have same behavior - 3 crosses go and try again.
> It's app for changing personal info on government issued documents -
> sorta wizard like thing. I can see how I can do it by keeping eye of
> parameters - but I am looking for cleanest possible implementation. But if I decide to modify default stack I am not certain what might
> be consequences for the rest of app.
None, if you do it right.
Since it's across the entire app I'd go the interceptor route--but you're still going to have to either use a hidden parameter, keep something in session, or whatever. Both have their advantages and disadvantages, but are basically the same complexity.
I'd probably consider modifying the <s:form> template to insert a hidden parameter, but that leaves it vulnerable to someone spoofing the validation count--if that's an issue. Otherwise you'd have to track a session variable, re-initialize it when a form is displayed for the first time, and so on.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Custom validation interceptor
Posted by Dave Newton <ne...@yahoo.com>.
Peter Bliznak wrote:
> It is across entire app (there are many dozen of actions) - every
> single action has to have same behavior - 3 crosses go and try again.
> It's app for changing personal info on government issued documents -
> sorta wizard like thing. I can see how I can do it by keeping eye of
> parameters - but I am looking for cleanest possible implementation.
> But if I decide to modify default stack I am not certain what might
> be consequences for the rest of app.
None, if you do it right.
Since it's across the entire app I'd go the interceptor route--but
you're still going to have to either use a hidden parameter, keep
something in session, or whatever. Both have their advantages and
disadvantages, but are basically the same complexity.
I'd probably consider modifying the <s:form> template to insert a hidden
parameter, but that leaves it vulnerable to someone spoofing the
validation count--if that's an issue. Otherwise you'd have to track a
session variable, re-initialize it when a form is displayed for the
first time, and so on.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Custom validation interceptor
Posted by Peter Bliznak <bl...@rogers.com>.
It is across entire app (there are many dozen of actions) - every single action has to have same behavior - 3 crosses go and try again.
It's app for changing personal info on government issued documents - sorta wizard like thing.
I can see how I can do it by keeping eye of parameters - but I am looking for cleanest possible implementation.
But if I decide to modify default stack I am not certain what might be consequences for the rest of app.
________________________________
From: Dave Newton <ne...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Saturday, June 20, 2009 7:57:24 PM
Subject: Re: Custom validation interceptor
Peter Bliznak wrote:
> I have following requirement: If validation of the page fails 3 times
> in row - invalidate session and redirect to index page. Should I
> replace default validation interceptor in default stack with my own
> to achieve what I am after? I there any other way?
Is this across the entire app or just a single action?
If it's just a single action then this could probably be done via a session var or a hidden counter (updated in the actions validate() method)... although I'm not sure how you'd tell the workflow interceptor to go to the "strike three" page.
AFAICT the workflow.inputResultName parameter doesn't eval OGNL, so you'd have to set the result location in the action--seems messy.
I started off thinking no on the interceptor, but now I'm not so sure.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Custom validation interceptor
Posted by Dave Newton <ne...@yahoo.com>.
Peter Bliznak wrote:
> I have following requirement: If validation of the page fails 3 times
> in row - invalidate session and redirect to index page. Should I
> replace default validation interceptor in default stack with my own
> to achieve what I am after? I there any other way?
Is this across the entire app or just a single action?
If it's just a single action then this could probably be done via a
session var or a hidden counter (updated in the actions validate()
method)... although I'm not sure how you'd tell the workflow interceptor
to go to the "strike three" page.
AFAICT the workflow.inputResultName parameter doesn't eval OGNL, so
you'd have to set the result location in the action--seems messy.
I started off thinking no on the interceptor, but now I'm not so sure.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Custom validation interceptor
Posted by Wes Wannemacher <we...@wantii.com>.
I don't think a custom interceptor is required. You could probably get
this done through hidden parameters or by storing attempts in the
session or something. Do you have this req for one action or all
actions in the app?
On 6/20/09, Peter Bliznak <bl...@rogers.com> wrote:
> Hi,
> I have following requirement:
> If validation of the page fails 3 times in row - invalidate session and
> redirect to index page.
> Should I replace default validation interceptor in default stack with my own
> to achieve what I am after?
> I there any other way?
> Any hint would be greatly appreciated
>
> Peter.
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org