Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"reset " button not working properly

 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • 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....
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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.)
 
Junilu Lacar
Bartender
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic