You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shehryar Khan <kh...@ubermind.com> on 2001/09/15 05:51:07 UTC
Multiple Submit Buttons per Form
I'm pretty new to struts so please forgive me if this question been asked
before (I searched the archives and didn't find anything like it). I have
an OPENSTEP / WebObjects background.
Is it possible to have 2 submit buttons (or image buttons) within the same
form that route to different action classes?
For example if I have a page that has a popup and 2 buttons (maybe a create
button and a modify button). I'd like the create button to invoke
perform(blah) on a CreateAction class and the modify button to invoke
perform(blah) on a ModifyAction class.
1 way to do it could be to put both buttons in different forms. However
that won't work because I want to check the selection in the popup in both
my create and modify classes.
Another way to do it could be route both buttons to a single action class,
which would conditionalize based on which button was clicked. I find this
approach particularly inelegant tho.
Anybody done anything like this? If so how did u set this up?
thanks.
-shehryar
Re: Multiple Submit Buttons per Form
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
One alternative is to use the Struts DispatchAction as a base class for a
single action, but you'll be able to implement multiple methods with the
same signature as 'perform' and control which of those methods is invoked by
a single query string parameter or hidden form field.
I also have used WebObjects (although not extensively) and would love to see
Struts evolve more towards it architecturally.
Erik
----- Original Message -----
From: "Shehryar Khan" <kh...@ubermind.com>
To: <st...@jakarta.apache.org>
Sent: Friday, September 14, 2001 8:51 PM
Subject: Multiple Submit Buttons per Form
>
> I'm pretty new to struts so please forgive me if this question been asked
> before (I searched the archives and didn't find anything like it). I have
> an OPENSTEP / WebObjects background.
>
> Is it possible to have 2 submit buttons (or image buttons) within the same
> form that route to different action classes?
>
> For example if I have a page that has a popup and 2 buttons (maybe a
create
> button and a modify button). I'd like the create button to invoke
> perform(blah) on a CreateAction class and the modify button to invoke
> perform(blah) on a ModifyAction class.
>
> 1 way to do it could be to put both buttons in different forms. However
> that won't work because I want to check the selection in the popup in both
> my create and modify classes.
>
> Another way to do it could be route both buttons to a single action class,
> which would conditionalize based on which button was clicked. I find this
> approach particularly inelegant tho.
>
> Anybody done anything like this? If so how did u set this up?
>
> thanks.
>
> -shehryar
>
>
Re: Multiple Submit Buttons per Form
Posted by ma...@tumbleweed.com.
Another alternative is to use JavaScript to set the form's action before
submitting it.
--
Martin Cooper
----- Original Message -----
From: "Shehryar Khan" <kh...@ubermind.com>
To: <st...@jakarta.apache.org>
Sent: Friday, September 14, 2001 8:51 PM
Subject: Multiple Submit Buttons per Form
>
> I'm pretty new to struts so please forgive me if this question been asked
> before (I searched the archives and didn't find anything like it). I have
> an OPENSTEP / WebObjects background.
>
> Is it possible to have 2 submit buttons (or image buttons) within the same
> form that route to different action classes?
>
> For example if I have a page that has a popup and 2 buttons (maybe a
create
> button and a modify button). I'd like the create button to invoke
> perform(blah) on a CreateAction class and the modify button to invoke
> perform(blah) on a ModifyAction class.
>
> 1 way to do it could be to put both buttons in different forms. However
> that won't work because I want to check the selection in the popup in both
> my create and modify classes.
>
> Another way to do it could be route both buttons to a single action class,
> which would conditionalize based on which button was clicked. I find this
> approach particularly inelegant tho.
>
> Anybody done anything like this? If so how did u set this up?
>
> thanks.
>
> -shehryar
>