You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Wade <kw...@mindspring.com> on 2008/01/02 22:00:51 UTC
Basic validation, input, and redirects
Greetings. I've seen a number of posts about this issue -- or related
issues -- but no comprehensive solution. I'll try again and be
succinct:
I have an action (Action1) that prepares a search screen (i.e.
populates a drop-down box). The search screen/form calls Action2 but
has a Action2-validation.xml file which specifies validation rules.
In my struts.xml file, the result type of "input" for Action2 will
redirect back to Action1 so that the search form is properly prepared
and displayed.
This isn't working as I would expect. The validation seems to work
fine but when the redirect to Action1 occurs on the result type of
"input"... Action1 is not running because it ALSO is trying to find a
result type of "input."
So... any ideas? I'm not sure why the "input" return type is
propagating from Action2 to Action1, but I gather that the presence of
the validation errors is triggering something in the
DefaultWorkflowInterceptor in Action1 when the re-direct back to it
occurs.
Any ideas how to make that not happen? How can I make validation not
run on Action1? Or, alternatively, make the Interceptor ignore the
validation errors after the redirect? I tried adding a
@SkipValidation annotation to the execute() method of Action1, but
that did nothing. Any ideas?
Kevin
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Basic validation, input, and redirects
Posted by Jack Gould <jj...@pobox.com>.
I'll expand on this comment (and I believe this is what ravi_eze is
suggesting)... I have a similar situation in my application, and I got
around it by creating a non-validating stack for the "setup" actions. I
basically removed all the interceptors that trigger validation for those
actions where I know I am redirecting (or forwarding) from another action
with error values.
- Jack
On Jan 3, 2008 12:23 AM, ravi_eze <ra...@yahoo.com> wrote:
>
> i think u can ty this way:
>
> create a new mapping where there are no validations for action 1. Now on
> validation errors of action 2 it would redirect to this action 1; thus
> skipping validations of action 1.
>
>
--
"Political will is a renewable resource." -- Al Gore, An Inconvenient Truth
Re: Basic validation, input, and redirects
Posted by ravi_eze <ra...@yahoo.com>.
i think u can ty this way:
create a new mapping where there are no validations for action 1. Now on
validation errors of action 2 it would redirect to this action 1; thus
skipping validations of action 1.
if u want the function call only and no validations... may b u can call the
method action1 when u detect an error executing aciton 1. or refactor...
hope this helps
kwade wrote:
>
> Thanks for the comment.
>
> The problem is not that I'm losing the validation errors. I'm keeping
> those across the redirect by using a modified interceptor stack with
> the STORE interceptor. So, that's cool.
>
> The problem is that *because* the errors are being preserved across
> the redirect (I think it's because), the validation/workflow
> interceptor for the action that is the destination of the "input"
> result type (back to 'Action1' that is) is ALSO picking up on the
> presence of those validation errors and ALSO looking for a place to go
> for an 'input' return type. It looks like this:
> Action1 -> search screen.jsp -> submit form -> Action2 -> (validation
> error found; input says 'Action1") -> Action1 -> (validation error
> found; looks for 'input' result type) -> Exception since there is no
> mapping for 'input' on Action1
>
> I wish it would just stop here:
> Action1 -> search screen.jsp -> submit form -> Action2 -> (validation
> error found; input says 'Action1") -> Action1
>
> I've worked on this some more and found a possible solution by further
> modifying the interceptor stack for Action1:
> <action name="Action1" method="execute" class="Action1">
> <interceptor-ref name="defaultStack">
> execute
> execute
> </interceptor-ref>
> <result name="success">searchQuery.jsp</result>
> </action>
>
> Now, the execute method of Action1 is excluded from validation. The
> propogating errors from Action2 don't cause a problem for Action1. I
> don't know if I need to exclude the execute method from BOTH
> validation and workflow interceptors, but it works. Any thoughts on
> that?
>
> I do have a second problem, though: the validation errors are
> remaining across multiple invocations of Action2. Even a successful
> (validated) form submission is not erasing the OLD validation errors.
> I need a way to remove the old errors after they are displayed.
> Anyone have any ideas on that too?
>
> Thanks as always,
> Kevin
>
> On Jan 2, 2008, at Wednesday, January 2, 2008 - 4:35 PM, Laurie
> Harper wrote:
>
>> Kevin Wade wrote:
>>> Greetings. I've seen a number of posts about this issue -- or
>>> related issues -- but no comprehensive solution. I'll try again
>>> and be succinct:
>>> I have an action (Action1) that prepares a search screen (i.e.
>>> populates a drop-down box). The search screen/form calls Action2
>>> but has a Action2-validation.xml file which specifies validation
>>> rules. In my struts.xml file, the result type of "input" for
>>> Action2 will redirect back to Action1 so that the search form is
>>> properly prepared and displayed.
>>> This isn't working as I would expect. The validation seems to work
>>> fine but when the redirect to Action1 occurs on the result type of
>>> "input"... Action1 is not running because it ALSO is trying to find
>>> a result type of "input."
>>> So... any ideas? I'm not sure why the "input" return type is
>>> propagating from Action2 to Action1, but I gather that the presence
>>> of the validation errors is triggering something in the
>>> DefaultWorkflowInterceptor in Action1 when the re-direct back to it
>>> occurs.
>>> Any ideas how to make that not happen? How can I make validation
>>> not run on Action1? Or, alternatively, make the Interceptor ignore
>>> the validation errors after the redirect? I tried adding a
>>> @SkipValidation annotation to the execute() method of Action1, but
>>> that did nothing. Any ideas?
>>> Kevin
>>
>> Unless you've configured something to preserve them, the validation
>> errors should be getting lost on the redirect (which is, of course,
>> not what you want in this scenario but is the default behavior).
>> What interceptor stack are you using? How are you preserving user
>> input across the redirect?
>>
>> I would suggest creating a minimal sample application demonstrating
>> the problem, then posting the relevant bits of code and
>> configuration for people to play with to diagnose what's happening.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
>
--
View this message in context: http://www.nabble.com/Basic-validation%2C-input%2C-and-redirects-tp14586204p14592027.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Basic validation, input, and redirects
Posted by Kevin Wade <kw...@mindspring.com>.
Thanks for the comment.
The problem is not that I'm losing the validation errors. I'm keeping
those across the redirect by using a modified interceptor stack with
the STORE interceptor. So, that's cool.
The problem is that *because* the errors are being preserved across
the redirect (I think it's because), the validation/workflow
interceptor for the action that is the destination of the "input"
result type (back to 'Action1' that is) is ALSO picking up on the
presence of those validation errors and ALSO looking for a place to go
for an 'input' return type. It looks like this:
Action1 -> search screen.jsp -> submit form -> Action2 -> (validation
error found; input says 'Action1") -> Action1 -> (validation error
found; looks for 'input' result type) -> Exception since there is no
mapping for 'input' on Action1
I wish it would just stop here:
Action1 -> search screen.jsp -> submit form -> Action2 -> (validation
error found; input says 'Action1") -> Action1
I've worked on this some more and found a possible solution by further
modifying the interceptor stack for Action1:
<action name="Action1" method="execute" class="Action1">
<interceptor-ref name="defaultStack">
<param name="validation.excludeMethods">execute</param>
<param name="workflow.excludeMethods">execute</param>
</interceptor-ref>
<result name="success">searchQuery.jsp</result>
</action>
Now, the execute method of Action1 is excluded from validation. The
propogating errors from Action2 don't cause a problem for Action1. I
don't know if I need to exclude the execute method from BOTH
validation and workflow interceptors, but it works. Any thoughts on
that?
I do have a second problem, though: the validation errors are
remaining across multiple invocations of Action2. Even a successful
(validated) form submission is not erasing the OLD validation errors.
I need a way to remove the old errors after they are displayed.
Anyone have any ideas on that too?
Thanks as always,
Kevin
On Jan 2, 2008, at Wednesday, January 2, 2008 - 4:35 PM, Laurie
Harper wrote:
> Kevin Wade wrote:
>> Greetings. I've seen a number of posts about this issue -- or
>> related issues -- but no comprehensive solution. I'll try again
>> and be succinct:
>> I have an action (Action1) that prepares a search screen (i.e.
>> populates a drop-down box). The search screen/form calls Action2
>> but has a Action2-validation.xml file which specifies validation
>> rules. In my struts.xml file, the result type of "input" for
>> Action2 will redirect back to Action1 so that the search form is
>> properly prepared and displayed.
>> This isn't working as I would expect. The validation seems to work
>> fine but when the redirect to Action1 occurs on the result type of
>> "input"... Action1 is not running because it ALSO is trying to find
>> a result type of "input."
>> So... any ideas? I'm not sure why the "input" return type is
>> propagating from Action2 to Action1, but I gather that the presence
>> of the validation errors is triggering something in the
>> DefaultWorkflowInterceptor in Action1 when the re-direct back to it
>> occurs.
>> Any ideas how to make that not happen? How can I make validation
>> not run on Action1? Or, alternatively, make the Interceptor ignore
>> the validation errors after the redirect? I tried adding a
>> @SkipValidation annotation to the execute() method of Action1, but
>> that did nothing. Any ideas?
>> Kevin
>
> Unless you've configured something to preserve them, the validation
> errors should be getting lost on the redirect (which is, of course,
> not what you want in this scenario but is the default behavior).
> What interceptor stack are you using? How are you preserving user
> input across the redirect?
>
> I would suggest creating a minimal sample application demonstrating
> the problem, then posting the relevant bits of code and
> configuration for people to play with to diagnose what's happening.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
Re: Basic validation, input, and redirects
Posted by Laurie Harper <la...@holoweb.net>.
Kevin Wade wrote:
> Greetings. I've seen a number of posts about this issue -- or related
> issues -- but no comprehensive solution. I'll try again and be succinct:
>
> I have an action (Action1) that prepares a search screen (i.e. populates
> a drop-down box). The search screen/form calls Action2 but has a
> Action2-validation.xml file which specifies validation rules. In my
> struts.xml file, the result type of "input" for Action2 will redirect
> back to Action1 so that the search form is properly prepared and displayed.
>
> This isn't working as I would expect. The validation seems to work fine
> but when the redirect to Action1 occurs on the result type of "input"...
> Action1 is not running because it ALSO is trying to find a result type
> of "input."
>
> So... any ideas? I'm not sure why the "input" return type is
> propagating from Action2 to Action1, but I gather that the presence of
> the validation errors is triggering something in the
> DefaultWorkflowInterceptor in Action1 when the re-direct back to it occurs.
>
> Any ideas how to make that not happen? How can I make validation not
> run on Action1? Or, alternatively, make the Interceptor ignore the
> validation errors after the redirect? I tried adding a @SkipValidation
> annotation to the execute() method of Action1, but that did nothing.
> Any ideas?
>
> Kevin
Unless you've configured something to preserve them, the validation
errors should be getting lost on the redirect (which is, of course, not
what you want in this scenario but is the default behavior). What
interceptor stack are you using? How are you preserving user input
across the redirect?
I would suggest creating a minimal sample application demonstrating the
problem, then posting the relevant bits of code and configuration for
people to play with to diagnose what's happening.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org