Originally posted by Chris Pat:
However I need to have the Reset button work.
The HTML reset button does "work" according to it's limited specified functionality. The trouble is that your definition of "works" seems to be different than that. If you write your own JavaScript code, you are completely in control of what "works" means or doesn't mean, so that may be your best option.
Rather than using <html:reset>, I would use <html:button>. Since you apparently have no use for the original functionality of the reset button, there's no point in using it. The button tag was specifically designed for use with JavaScript. It only does whatever you cause the onclick event to perform.
Sometimes I put a button on a form with the label "reset" when the function I want this button to perform is to reset the values of all input fields to the value they currently have in the database. For this function, the tag I use is <html:cancel>.
This produces a submit button that has some special meaning for Struts. First of all, it tells Struts not to run validation. That is, it doesn't call validate on your ActionForm, nor does it perform framework validations. Secondly, it sends a flag to the Action class. You can call the Action class method isCancelled to determine whether the cancel button was pressed, or whether a regular submit button was pressed. I then put logic in my Action class such that if isCancelled is true, I retrieve the values from the database and forward to the calling
JSP.
If this is the type of thing you're looking to do, great. If not, it sounds like an <html:button> with an onclick event calling your own JavaScript function is your best bet.
One other note: If you're using Struts 1.2.9 or above, you must specify cancellable=true when you define the action path in struts-config.xml in order to use the cancel button.