File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes form reset problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form reset problem " Watch "form reset problem " New topic

form reset problem

kapil patel
Ranch Hand

Joined: Sep 30, 2005
Posts: 33
I have got one problem. I was trying for very long but still no success.

I am filling up various selection optins from database using action (VolunteerRegiInitAction) and forwarding to jsp page (volunteerRegistration.jsp). From there, it submit for another action (). Everything is working fine. However, when I submit form with some wrong validated value, it shows errors - that is fine.

However, after showing errors, when I reset page using <html:reset /> it reset to previous submitted value. Please can you give idea if you know where I am wrong.


Thank you very much in advance. It is working perfactly fine.

kapil patel

"Either do it with 100% commitment or do not do it, because almost is not enough"
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It sounds like you're not quite understanding what the reset button is supposed to to. In HTML, a reset button restores all input fields to the value they had when that page was last sent from the server. The way that Struts validation works, A form is submitted, and if validation errors are found the page is redisplayed (sent back to the browser). At this point, the baseline values used by the HTML reset button are now set to these values. When the reset button is pressed it is these values that the page will return to.

Here's the workaround: Use the <html:cancel value="reset" > tag to create your button. This button causes a submit to occur, but bypasses validation. Then have your action check for "isCancelled()" to indicate that the cancel button was pressed, have it retrieve the values from the database and redisplay the JSP. That way, you restore the values to whatever they were the last time the data was saved to the database. If you're using Struts version 1.2.9, make sure you put the following in your action definition:

<set-property property="cancellable" value="true"/>

Consultant, Sima Solutions
I agree. Here's the link:
subject: form reset problem
It's not a secret anymore!