• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

"reset " button not working properly

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi:
all, I use the validate() method of ActionForm to help me validate some inputs in the form in my JSP page, but I have encountered a strange error....

let us say if one of the input fields is invalid, then it will return to the original JSP page with the error msg(s), however, when that happens, my "Reset" button doesn't work properly, meaning, if i click the "reset" button , it won't clear out the fields for me.

But my "reset" button does clear out the fields when the user FIRST enters the JSP page,

so I thought it was rather strange, can sombody please lend me a hand?
many thanks....
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reset doesn't clear the values, it turns them back into the defaults.

If you view the source of the page check out the value attributes of the textfields. Those are the values it will default to when reset is clicked.
 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so are you saying if i do the following


and when i click on the "reset" button, the text fields will be cleard? since value=""???

let me know please


many thanks..
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. But I think that also means it will also override the prepopulation of values as well. (Everything will always be blank when you enter the page.)
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by dog lin:
But my "reset" button does clear out the fields when the user FIRST enters the JSP page,

so I thought it was rather strange, can sombody please lend me a hand?
many thanks...



Marc is correct, the reset button does not clear the fields values, it restores them to the values that they had when the page was initially displayed. It just so happens that when you go to the page the first time, there are no values in the fields. In subsequent requests for the page where fields are prepopulated, reset simply restores the prepopulated values.

The processing of the regular "reset" button is entirely on the client side; no request is sent to the server. What I normally do to solve this problem is to use a Submit button instead with a value of "reset". Then I can make the receiving Action handle "reset" request by clearing the appropriate fields in the ActionForm.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic