struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Loren Hall" <lorenh...@attbi.com>
Subject RE: reset doesn't work well
Date Sat, 21 Dec 2002 03:31:21 GMT
> " public void reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
> Reset all bean properties to their default state. This method is called
before the properties are repopulated by the > >
> controller servlet.

My log indicates that the controller is populating a recycled form bean AND
THEN resetting it ?!?

LOG DATA {

Processing a POST for /customize
2002-12-20 15:36:32 action:  Looking for ActionForm bean under attribute
'ModelForm'
2002-12-20 15:36:32 action:  Recycling existing ActionForm bean instance of
class 'Insites.theSystem.ModelForm'
2002-12-20 15:36:32 action:  Populating bean properties from this request
2002-12-20 15:36:32 action:
reset called

}

( "reset called" printed from my reset() override)


I initial avoided the problem by overriding reset() to do nothing except set
the checkbox variable to address the issue with unchecking, and to print the
"reset called" message above.  I also have validate=false

But, complications with that "solution" appear unavoidable.  Anybody seen
this behavior before?

I'm Using stable struts version 1.0.2 . . . and I'm also new to Struts,


thanks

Loren









-----Original Message-----
From: Doug Ogateter [mailto:hinbsls@yahoo.ca]
Sent: Friday, December 20, 2002 1:17 PM
To: Struts Users Mailing List
Subject: RE: reset doesn't work well



Hi, Bill:
Thank you for reply.
The ActionForm api says:

   " public void reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)

   Reset all bean properties to their default state. This method is called
before the properties are repopulated by the controller servlet.
The default implementation does nothing. Subclasses should override this
method to reset all bean properties to default values. "





I have overitten the reset method to reset both amount and password to null.
>From my understanding, whenever user clicks reset button, it will call the
reset method, therefore, all the fields should be cleared.


Please correct me if I am wrong.


Thanks

 "Siggelkow, Bill" <bill.siggelkow@mirant.com> wrote:The really has nothing
to do with the reset method of your form ... instead this renders an
[input]  button that will reset the form fields to their "default" state as
known by the browser. Therefore, in the case when you have returned to the
form after a validation failure the default values are the values in the
form bean returned to the input page. I see a couple of options ..

1) You could have your validate() method clear out the fields that erroneous
(or clear them all out if you want) if the validation fails.

2) If you truly want the reset button to erase all fields regardless of the
pre-populated values you could do this with an onclick event calling
JavaScript.

Personally, I would go with option 1 as it will not confuse the user about
what the Reset button does.

-----Original Message-----
From: Doug Ogateter [mailto:hinbsls@yahoo.ca]
Sent: Friday, December 20, 2002 3:38 PM
To: Struts Users Mailing List
Subject: reset doesn't work well



Hi:
I have a problem with reset button. In my jsp file, I have . In my form
class, I have:

public void reset(ActionMapping mapping, HttpServletRequest request) {
amount = null;

password = null;
}

in the struts-config.xml file, it has:

type="yyy"
name="myForm"
scope="request"

input="/zzz.jsp">



I filled out the fields, if I click reset button before submit the form, the
fields are cleared. But if I submit the form first, and it detects some
error(for example: the password is not correct), the form is showed with
error message. In this case, when I click reset button, the fields are not
cleared. What is wrong with this. I really want the fields can be cleared if
errors are detected. Could someone help me out?

Thanks.

Doug



---------------------------------
Post your free ad now! Yahoo! Canada Personals

--
To unsubscribe, e-mail:
For additional commands, e-mail:



---------------------------------
Post your free ad now! Yahoo! Canada Personals



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


Mime
View raw message