That would be one solution, but in my case I have 4 submit buttons,
two of which redirect the user to another action (keeping scope set to session)
and then back to the original form.

I do not want the validation to be carried out either of these two buttons but 
only on the SAVE submit button.
(if that make sense!)



-----Oorspronkelijk bericht-----
Van: Christopher Schultz [mailto:[EMAIL PROTECTED]
Verzonden: dinsdag 14 november 2006 14:48
Aan: Struts Users Mailing List
Onderwerp: Re: Validation + multiple Submit buttons


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew,

Andrew Martin wrote:
> I have just begun to add validation to my forms using struts
> validator, which is quite nice. I have however a problem when I have
> more than one submit button on a form.
> 
> For example I have a Save button and a Back button. The Back button
> is also a submit (instead of a standard button - basically because we
> are creating a JS free applciation!)
> 
> Within the struts configuration the validate is set to true for this
> action with an input page defined. The validation is set to check
> certain fields are not empty.

What you want to do is to set your back button to be a "cancel" button.
This is done differently depending on which content-builder you are
using (JSP, Velocity, or whatever), but basically you have to end up
naming the button "org.apache.struts.taglib.html.CANCEL", which
indicates to struts that validation should be skipped. (Note that struts
1.2.7 (?) and higher require you to set a property for each action
mapping that indicates that the action is cancellable).

Note that, even though the validation is skipped, the form bean being
used for validation is *still* filled with this non-validated data.

If you are using a multi-page form bean, this is ideal: the user goes
BACK, changes something on the previous page, and then when they come
forward, again, you can redisplay the information they already entered
into the form. Once they submit *that*, you perform the validation and
move on.

Of course, if you want BACK, NEXT, and CANCEL buttons on the page, then
you can't really use this solution.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFWckq9CaO5/Lv0PARAjU2AJsHj3tDfnajq4v6FlOm+IW3hXabkwCfUXXm
HOv3KWS1mMon6Bbn32qnbCo=
=iLZY
-----END PGP SIGNATURE-----

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

Reply via email to