You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DHarty <ha...@db.erau.edu> on 2001/07/11 20:26:24 UTC

Session Form Reset?

Why does the servlet call the reset method of an action form even when it's
been put in the session scope?

It doesn't do much good if my session bean is reset to null after every
request!

D


RE: Session Form Reset?

Posted by DHarty <ha...@db.erau.edu>.
Gregor, you bring up an interesting point.

I have a form that has a boolean "grant" property that is selected by a
checkbox.  After the origional form is submitted, a second page uses that
form for verification purposes.

The problem is that if "grant" is true, and then the user decides to revoke
grant, he can uncheck the box.  However, as we all know, struts cannot see
this unchecking.

If I allow the box to be reset in the reset method, the grant property also
gets reset by the time it makes it to the verification page, and thus
becomes impossible to actually "grant" anything.  If I remove the reset
functionality, it become impossible to revoke the "grant".

I could create a second boolean property (grantCheckBox) that could be used
by the page to set the grant variable before it itself is reset, but how
would I get the checkbox to set itself when the page is initially viewed if
the origional grant property is true?

I would like to do something like...

public reset(...)
{
	grant = grantCheckBox;
	grantCheckBox=false;
}

then in my page:

	<html:checkbox property="grantCheckBox" value="grant"/>

but I know that there are several problems with this such as value="grant"
isn't supposed to be used to set the initial value.

I hope this discussion isn't to convoluted, but it seems any solution on one
hand just causes a problem on the other.

Thanks
D



-----Original Message-----
From: Gregor Rayman [mailto:grayman@gmx.net]
Sent: Wednesday, July 11, 2001 5:29 PM
To: struts-user@jakarta.apache.org
Subject: Re: Session Form Reset?


"DHarty" <ha...@db.erau.edu> wrote:

> Why does the servlet call the reset method of an action form even when
it's
> been put in the session scope?
>
> It doesn't do much good if my session bean is reset to null after every
> request!
>
> D

The reset method takes the request as a parameter. Make your reset
method smart enough to clear only properties, which should be
cleared. (like checkboxes displayed on the page which is beeing
submitted)

The same for validate.

--
gR


Re: Session Form Reset?

Posted by Gregor Rayman <gr...@gmx.net>.
"DHarty" <ha...@db.erau.edu> wrote:

> Why does the servlet call the reset method of an action form even when
it's
> been put in the session scope?
>
> It doesn't do much good if my session bean is reset to null after every
> request!
>
> D

The reset method takes the request as a parameter. Make your reset
method smart enough to clear only properties, which should be
cleared. (like checkboxes displayed on the page which is beeing
submitted)

The same for validate.

--
gR