File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Reset button & Validation Error

Satish Kulkarni
Ranch Hand

Joined: Jul 19, 2003
Posts: 60
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.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

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

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link:
subject: Reset button & Validation Error
It's not a secret anymore!