You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Yu <jo...@scioworks.com> on 2002/08/29 06:21:54 UTC

Re: Redirect and ActionErrors don't play together--is there another way?

Hi Dennis,

saveErrors() stores the ActionErrors in the request. Since doing a 
'redirect' creates a new request, you will lose the errors.

What you can do is:

1. in create.do, put the ActionErrors into the session and then redirect to 
table.do
2. in table.do, remove the ActionErrors from the session and use it to call 
saveErrors()
3. forward to the jsp.

Besides, while the following post doesn't address directly your issue, it 
is relevant:

   http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-user@jakarta.apache.org&msgId=448820


At 11:12 pm 28-08-2002, you wrote:
>Here's my situation: I have a screen that contains a table of objects
>(say the screen is displayed by "table.do"). There is a link on the
>screen that causes a new object to be created by a Struts action (call
>it "create.do?key=NN"). The action forwards back to "table.do". If the
>creation was successful, the table should now show the list of objects
>with the newly-created one added. If the creation failed, the table
>should display along with an error message.
>
>Here's my problem: when the "Create" link is clinked, the Action that
>does the work needs to do a redirect forward to "table.do". Otherwise
>you end up with "create.do?key=NN" in the browser location bar, and if
>the user then does a refresh on the table screen, instead of refreshing
>table.do the browser attempts to refresh create.do, which is wrong. The
>redirect solves this problem, except for error cases. If creation fails,
>I want to display an error message on the table screen. But all
>ActionErrors associated with the request are lost when I redirect.
>
>Any workarounds?

-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610

Scioworks Camino - "Don't develop Struts Apps without it!"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>