Jennifer Jacobs wrote:
Hello,
I have a number of Struts forms that are using the Validator.  This works
great except for on a couple of the forms.  The ones in question have two
submit buttons on them.  One updates the form somehow - calculates a
subtotal, or adds an attachment to a list of attachments, etc.  And the
other actually submits the form.

How to do I turn OFF the validation for the subtotal calculation, etc.
buttons?  I don't want to validate the data until the form is actually
submitted.
The way form submission works is that the data isn't validated until it's submitted. So I'm assuming you have two buttons like this:

button1->submit->validate->action->update form->redisplay form
button2->submit->validate->action->...

And you want to remove the validate step of the button1 flow. You could always set 'validate="false"' in your action mapping, and then call validate() manually in your action:

public ActionForward execute( ... ) {
 if ( button2WasClicked() ) {
   errors = form.validate(...);
 }
 ...
}

The only problem there is you can't rely on the "input" attribute of the action to return to the form and would have to use an action forward instead (which is fine, though honestly you can probably find the input attribute somewhere in the ActionMapping class, as Struts has to do this too when validation fails).

- Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to