struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Siggelkow, Bill" <bill.siggel...@mirant.com>
Subject RE: reset doesn't work well
Date Fri, 20 Dec 2002 20:46:57 GMT
The <html:reset> really has nothing to do with the reset method of your form ... instead
this renders an <input type="reset"> 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 <html:reset/>. 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:

   <action    path="/xxx"
               type="yyy"
               name="myForm"
              scope="request"

              input="/zzz.jsp">
          <forward name="success"             path="/zzz.jsp"/>    
    </action>

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:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message