You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben <ne...@gmail.com> on 2005/07/04 09:35:00 UTC

ActionForm reset() and redirect.

Hi

My form has some boolean properties and I set them to false in the
reset method. The Action that handles the form has redirect attribute
as true, i.e if there is an error, it redirects to the same page that
has the form with errors. When it redirects with errors, the form
retains values for other properties except the boolean ones. What I
can do to fix this? If I don't set the boolean properties to false in
the reset method, the form works fine.

Please help, thanks.
Ben

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


Re: ActionForm reset() and redirect.

Posted by Michael Jouravlev <jm...@gmail.com>.
On 7/4/05, Ben <ne...@gmail.com> wrote:
> Hi
> 
> My form has some boolean properties and I set them to false in the
> reset method. The Action that handles the form has redirect attribute
> as true, i.e if there is an error, it redirects to the same page that
> has the form with errors. When it redirects with errors, the form
> retains values for other properties except the boolean ones. What I
> can do to fix this? If I don't set the boolean properties to false in
> the reset method, the form works fine.
> 
> Please help, thanks.
> Ben

Apparently you use form bean with session scope, and you are
redirecting to the same action. When you redirect, no parameters are
passed in the request, so your boolean fields are not be set.

You need to clear boolean values only when you submit input data
(POST), but not when you redirect to the same action to redisplay the
page (GET).

You may want to give a try to the Struts Dialogs library, which
already handles this scenario. Here is the use case which seems like
yours: http://struts.sourceforge.net/strutsdialogs/dialogaction-logindialogsample.html
And here is the live demo, it looks simple, but remember, that it
works correctly with redirection, and with Refresh/Back buttons:
http://www.superinterface.com/strutsdialog/logindialog.html

Michael.

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


RE: ActionForm reset() and redirect.

Posted by Nitesh Naveen <ni...@cordiant.net>.
Try putting in some logic where ever you are assigning the value... like if
it is not set then set it to false... if it is already set don't touch it!

HTH
Nitesh

-----Original Message-----
From: Ben [mailto:newreaders@gmail.com] 
Sent: Monday, July 04, 2005 1:05 PM
To: Struts
Subject: ActionForm reset() and redirect.

Hi

My form has some boolean properties and I set them to false in the
reset method. The Action that handles the form has redirect attribute
as true, i.e if there is an error, it redirects to the same page that
has the form with errors. When it redirects with errors, the form
retains values for other properties except the boolean ones. What I
can do to fix this? If I don't set the boolean properties to false in
the reset method, the form works fine.

Please help, thanks.
Ben

---------------------------------------------------------------------
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