This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
******** struts-config.xml ********
Thank you very much in advance. It is working perfactly fine.
"Either do it with 100% commitment or do not do it, because almost is not enough"
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: