File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Reset button & Validation Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Reset button & Validation Error" Watch "Reset button & Validation Error" New topic
Author

Reset button & Validation Error

Satish Kulkarni
Ranch Hand

Joined: Jul 19, 2003
Posts: 60
Hi,
I have a form "ModfyUserForm" with "Submit" button and a "Reset" button. The form is prepopulated depending on what user is selected from a dropdown list. When you edit a certain field in the form and before clikcing Submit you click Reset my previous data is loaded back in the form. But while modifying if any field(like emailaddress field) is empty I throw a Validation Error.
But after the Validation Error if I click the Reset button the old values are not retrieved and the form is not populated with the old data. Is there a way to make this...if could you please let me know.
Thanks in advance.
-Satish
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

Reset restores fields with the values they had when the page was originally loaded. When you come back with validation errors, the data that you validated now become the original values. The values that you had before validation are lost. The only way you can restore the values you really wanted would be to change your reset button to a submit button and pull the original values back into the form fields on the server side. That is, instead of
<html:reset />
you would have
<html:submit>Reset</html:submit>


Junilu - [How to Ask Questions] [How to Answer Questions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reset button & Validation Error
 
Similar Threads
Problem in Reset button.
Reset the form to Null or Reload the page using reset even after a submit
Regarding "html: reset " button
java script
Struts 2 : Does s:reset is really capable for reset ?