You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcos Mendonça <ma...@gmail.com> on 2008/01/16 12:51:15 UTC

[struts2] Redirecting to different pages on validate method

Hello

I have two diferrent jsp for an action. Its works all right, only
problem is that, if there are validation errors it always returns to
the same jsp, and that sometimes it's not the jsp that posted the
data.

What configuration I have to do in struts.xml or how to I decide on
the validate method wich jsp it will render on validation errors?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts2] Redirecting to different pages on validate method

Posted by Dave Newton <ne...@yahoo.com>.
Another possible solution is to use an OGNL expression as the value for the
"input" result element and use either a form property or a non-form action
property for the value.

You could also set the "inputResultName" on the workflow interceptor [1],
although that might not be as flexible of a solution: I'm not sure if the
value for that is parsed.

In general, though, using the same action/validation to process different
form submissions strikes me as a little fishy. It seems like things could be
re-architected or re-configured to make use of the underlying validation
and/or action processing without resorting to any trickery (albeit minor, in
this case).

d.

[1] http://struts.apache.org/2.x/docs/workflow-interceptor.html

--- Ted Husted <hu...@apache.org> wrote:

> One of the results to the action stanza should be named "input". The
> "input" result is the one that is selected when validation fails.
> 
> For an individual action, it looks something like this:
> 
>         <action name="Login"  class="mailreader2.Login">
>             <result name="input">/Login.jsp</result>
> 
> A default input result can also be set for an entire package, and then
> changed for individual actions, as needed.
> 
>     <package name="subscription" namespace="/"
> extends="mailreader-support">
>         <global-results>
>             <result name="input">/Subscription.jsp</result>
>         </global-results>
> 
> HTH, Ted
> <http://www.StrutsMentor.com/>
> 
> On Jan 16, 2008 6:51 AM, Marcos Mendonça <ma...@gmail.com> wrote:
> > Hello
> >
> > I have two diferrent jsp for an action. Its works all right, only
> > problem is that, if there are validation errors it always returns to
> > the same jsp, and that sometimes it's not the jsp that posted the
> > data.
> >
> > What configuration I have to do in struts.xml or how to I decide on
> > the validate method wich jsp it will render on validation errors?
> >
> > Thanks
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> 
> --
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts2] Redirecting to different pages on validate method

Posted by Ted Husted <hu...@apache.org>.
One of the results to the action stanza should be named "input". The
"input" result is the one that is selected when validation fails.

For an individual action, it looks something like this:

        <action name="Login"  class="mailreader2.Login">
            <result name="input">/Login.jsp</result>

A default input result can also be set for an entire package, and then
changed for individual actions, as needed.

    <package name="subscription" namespace="/" extends="mailreader-support">
        <global-results>
            <result name="input">/Subscription.jsp</result>
        </global-results>

HTH, Ted
<http://www.StrutsMentor.com/>

On Jan 16, 2008 6:51 AM, Marcos Mendonça <ma...@gmail.com> wrote:
> Hello
>
> I have two diferrent jsp for an action. Its works all right, only
> problem is that, if there are validation errors it always returns to
> the same jsp, and that sometimes it's not the jsp that posted the
> data.
>
> What configuration I have to do in struts.xml or how to I decide on
> the validate method wich jsp it will render on validation errors?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



--

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org