Doug, I think you are misreading or misinformed about both the reset button and the 
reset method.  The "reset" button does a client-side reset of the form -- there is no 
interaction with the server.

The reset method is called by the ActionServlet when a form is reused -- but I do not 
think that it is called on when validate returns false -- in fact, I would think that 
you would not want it called so that the user does not "lose" all of their previous 
input.

-----Original Message-----
From: Doug Ogateter [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 20, 2002 4: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" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]]
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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to