You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mucus snot <mu...@virgin.net> on 2004/03/05 12:17:26 UTC
redirects / actionErrors
Hi,
I am using action errors as a means of passing messages to the request:
e.g.
in Action, execute method...
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.to.user"));
saveErrors(request, errors);
return mapping.findForward(Constants.REDIRECT_KEY);
But if I redirect from this action to another forward that is also an
action, the actionError is out of scope.
I would be interested to know if
(a) this is good practice - to forward to another forward (it seems to work
for me)
(b) there is an easy way to carry the actionError forward within storing in
the session, and saving it in the redirected request.
Hope I'm making sense,
Thanks, al
Re: redirects / actionErrors
Posted by Daniel Henrique Alves Lima <em...@yahoo.com.br>.
Hi,
I don't know if i could understand your doubt (correct me if i'm
wrong) but you must "forward" to your .jsp page and not "redirect"...
If you have a global forward (in your struts-config.xml) like
<forward name="/my_forward_name" path="/my_jsp.jsp" redirect="false"\>
the request will be "forwarded" to the .jsp resource. But if you have
<forward name="/my_forward_name" path="/my_jsp.jsp" redirect="true"\>
the request will "redirected" (then you will "lose" the attributes
in your request)
mucus snot wrote:
> Hi,
>
> I am using action errors as a means of passing messages to the request:
>
> e.g.
>
> in Action, execute method...
>
> errors.add(ActionErrors.GLOBAL_ERROR, new
> ActionError("message.to.user"));
> saveErrors(request, errors);
> return mapping.findForward(Constants.REDIRECT_KEY);
>
> But if I redirect from this action to another forward that is also an
> action, the actionError is out of scope.
>
> I would be interested to know if
> (a) this is good practice - to forward to another forward (it seems to
> work for me)
> (b) there is an easy way to carry the actionError forward within
> storing in the session, and saving it in the redirected request.
>
> Hope I'm making sense,
>
> Thanks, al
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: redirects / actionErrors
Posted by Hubert Rabago <ja...@yahoo.com>.
Struts 1.2 has a feature you can use that allows you to store your
ActionMessages in session variables, then have it removed once they're
accessed. I haven't used this yet, but you can probably build on this by
storing your errors before you redirect, then have them displayed by the
resource your redirected to.
Another option is the extensions at http://www.rabago.net/struts/redirect
which actually adds your messages (error or not) to the url paramters and
puts them back on the ActionMessages queue upon redirection.
hth,
Hubert
--- mucus snot <mu...@virgin.net> wrote:
> Hi,
>
> I am using action errors as a means of passing messages to the request:
>
> e.g.
>
> in Action, execute method...
>
> errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.to.user"));
> saveErrors(request, errors);
> return mapping.findForward(Constants.REDIRECT_KEY);
>
> But if I redirect from this action to another forward that is also an
> action, the actionError is out of scope.
>
> I would be interested to know if
> (a) this is good practice - to forward to another forward (it seems to work
>
> for me)
> (b) there is an easy way to carry the actionError forward within storing in
>
> the session, and saving it in the redirected request.
>
> Hope I'm making sense,
>
> Thanks, al
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org