This works perfectly, a simple action to check which submit button is clicked 
forwards the three pages without validation to appropriate location.
Actual Save button calls a commit action where validation is required.

Thanks for the help

Andrew

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


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

Andrew,

Andrew Martin wrote:
> 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.

Hmm... that makes things more interesting.

How about this:

You create a new action called "figureItOutAction" or something like
that, and POST your form to that action. This action has no form bean,
no validation, no nuthin'.

In that action, you look for the names of the buttons that you want to
use, say: SAVE, BACK, CANCEL, and FOURTH_BUTTON (or whatever). Then, you
dispatch based upon the button that was pressed:

in struts-config.xml:
<forward name="save" path="..../save.do" />
<forward name="back" path="..../back.do" />
.
.
.

Remember to definitely NOT set redirect="true", since we need the reques
to stay in tact.

Your code for FigureItOutAction will look like this:

if(null != request.getParameter("save"))
   return mapping.findForward("save");
else if(null != request.getParameter("back"))
   return mapping.findForward("back");
.
.
.

Then, just point each of these dispatching actions to the ones that
really do the work. Each of these may have validation, form beans, etc.
For instance, your "save" action (or "next"... whatever) will have a
form bean and validate="true" in struts-config.xml.

This trick allows you to submit your form to an action which decides
what to do independently of validation. Forwarding on to another action
that /does/ validate will then give you the magic of validation.

I haven't tried this before, but it should work.

- -chris

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

iD8DBQFFWdRw9CaO5/Lv0PARAra+AJ9zZ4ejuncDFJXlQHicNXykEh9EWACgqTBJ
GTAT1awgUG4RugUt/9jQNmw=
=jcpP
-----END PGP SIGNATURE-----

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

Reply via email to