You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Al Sutton <al...@alsutton.com> on 2007/05/22 18:21:57 UTC

[s2] Best method of passing ActionErrors through a redirect

Simple question; 
 
Is there any way to retain messages added with addActionError or
addActionMessage during a redirect?
 
 
 
More complex explanation of my setup;
 
ActionA gets data and has uses a jsp to display the data (using
<result>my_jsp.jsp</result>). 
my_jsp.jsp has a comment field which submits data to ActionB
ActionB processes the comment and then should send the user to ActionA which
gets the data with the new comment and re-displays the jsp.
 
To go from ActionB to ActionA I use a redirect, but the redirect seems to
cause anything added with addActionError or addActionMessage to get dropped
and so the jsp doesn't display them.
 
 
Any suggestions on what to do?

Re: [s2] Best method of passing ActionErrors through a redirect

Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,

if its struts2, take a look at this...

http://struts.apache.org/2.x/docs/message-store-interceptor.html

Thanks,

Nuwan


----- Original Message ----- 
From: "Al Sutton" <al...@alsutton.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Tuesday, May 22, 2007 4:21 PM
Subject: [s2] Best method of passing ActionErrors through a redirect


> Simple question;
>
> Is there any way to retain messages added with addActionError or
> addActionMessage during a redirect?
>
>
>
> More complex explanation of my setup;
>
> ActionA gets data and has uses a jsp to display the data (using
> <result>my_jsp.jsp</result>).
> my_jsp.jsp has a comment field which submits data to ActionB
> ActionB processes the comment and then should send the user to ActionA 
> which
> gets the data with the new comment and re-displays the jsp.
>
> To go from ActionB to ActionA I use a redirect, but the redirect seems to
> cause anything added with addActionError or addActionMessage to get 
> dropped
> and so the jsp doesn't display them.
>
>
> Any suggestions on what to do?
> 


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


RE: [s2] Best method of passing ActionErrors through a redirect

Posted by Al Sutton <al...@alsutton.com>.
Thanks for the suggestions. It just felt a little weird that the recommended
method of dealing with POSTed data (i.e. post and redirect) whacks out the
standard provided method of passing user messages (addActionError and
addActionMessage).

Is this something which could be "improved" in future releases?, Is there
any reason why the method employed by the Store interceptor is not standard
so that action errors and messages could be propagated across redirects?

-----Original Message-----
From: Lance [mailto:lance.semmens@marketpipe.com] 
Sent: 22 May 2007 17:42
To: Struts Users Mailing List
Subject: Re: [s2] Best method of passing ActionErrors through a redirect

You could forward rather than redirect.
Another option is to use "flash scope" which has been discussed on this list
previously. My understanding of this is that a filter manages a map on the
session and requests have access to attributes added by the previous
request.

I have never implemented the latter but it sounds kinda cool.

Raghupathy, Gurumoorthy wrote:
> Redirect looses all data .. this is how it is to work .... 
> One thing you can do is store it as a session attribute :) ... not the 
> best way but one of the way
>
>
> Regards
> Guru
>
> -----Original Message-----
> From: Al Sutton [mailto:al.sutton@alsutton.com]
> Sent: 22 May 2007 17:22
> To: 'Struts Users Mailing List'
> Subject: [s2] Best method of passing ActionErrors through a redirect
>
> Simple question;
>  
> Is there any way to retain messages added with addActionError or 
> addActionMessage during a redirect?
>  
>  
>  
> More complex explanation of my setup;
>  
> ActionA gets data and has uses a jsp to display the data (using 
> <result>my_jsp.jsp</result>).
> my_jsp.jsp has a comment field which submits data to ActionB ActionB 
> processes the comment and then should send the user to ActionA which 
> gets the data with the new comment and re-displays the jsp.
>  
> To go from ActionB to ActionA I use a redirect, but the redirect seems 
> to cause anything added with addActionError or addActionMessage to get 
> dropped and so the jsp doesn't display them.
>  
>  
> Any suggestions on what to do?
>
> ---------------------------------------------------------------------
> 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: [s2] Best method of passing ActionErrors through a redirect

Posted by Lance <la...@marketpipe.com>.
You could forward rather than redirect.
Another option is to use "flash scope" which has been discussed on this 
list previously. My understanding of this is that a filter manages a map 
on the session and requests have access to attributes added by the 
previous request.

I have never implemented the latter but it sounds kinda cool.

Raghupathy, Gurumoorthy wrote:
> Redirect looses all data .. this is how it is to work .... 
> One thing you can do is store it as a session attribute :) ... not the
> best way but one of the way 
>
>
> Regards
> Guru
>
> -----Original Message-----
> From: Al Sutton [mailto:al.sutton@alsutton.com] 
> Sent: 22 May 2007 17:22
> To: 'Struts Users Mailing List'
> Subject: [s2] Best method of passing ActionErrors through a redirect
>
> Simple question; 
>  
> Is there any way to retain messages added with addActionError or
> addActionMessage during a redirect?
>  
>  
>  
> More complex explanation of my setup;
>  
> ActionA gets data and has uses a jsp to display the data (using
> <result>my_jsp.jsp</result>). 
> my_jsp.jsp has a comment field which submits data to ActionB
> ActionB processes the comment and then should send the user to ActionA
> which
> gets the data with the new comment and re-displays the jsp.
>  
> To go from ActionB to ActionA I use a redirect, but the redirect seems
> to
> cause anything added with addActionError or addActionMessage to get
> dropped
> and so the jsp doesn't display them.
>  
>  
> Any suggestions on what to do?
>
> ---------------------------------------------------------------------
> 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: [s2] Best method of passing ActionErrors through a redirect

Posted by "Raghupathy, Gurumoorthy" <Gu...@nielsen.com>.
Redirect looses all data .. this is how it is to work .... 
One thing you can do is store it as a session attribute :) ... not the
best way but one of the way 


Regards
Guru

-----Original Message-----
From: Al Sutton [mailto:al.sutton@alsutton.com] 
Sent: 22 May 2007 17:22
To: 'Struts Users Mailing List'
Subject: [s2] Best method of passing ActionErrors through a redirect

Simple question; 
 
Is there any way to retain messages added with addActionError or
addActionMessage during a redirect?
 
 
 
More complex explanation of my setup;
 
ActionA gets data and has uses a jsp to display the data (using
<result>my_jsp.jsp</result>). 
my_jsp.jsp has a comment field which submits data to ActionB
ActionB processes the comment and then should send the user to ActionA
which
gets the data with the new comment and re-displays the jsp.
 
To go from ActionB to ActionA I use a redirect, but the redirect seems
to
cause anything added with addActionError or addActionMessage to get
dropped
and so the jsp doesn't display them.
 
 
Any suggestions on what to do?

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