You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Johnson <ch...@gmail.com> on 2005/04/15 15:37:07 UTC

a Form with different actions actions

All

I have a large page with a form on it that I need to submit to
diffferent actions depending on that the user clicks.

For example, I have on this page

0. a list of items the user can select 1-->n of (using checkboxes)
1. a list of graph types, with a "graph chosen now" button (user
chooses things from item #0 above)
2. a list of reports, with a "report chosen now" button (user chooses
things from item #0 above)
3. a "combine selected" buttons (again user chooses things from item #0 above)
4. a "create new" button

Essentially I may need to access some or ALL of the form fields seen
on the page regardless of which path the user takes, so I assume that
means one big form.

the problem is I want to submit to "graphAction" for graphs or
"reportAction" for reports or "combineAction" etc.

how is this kind of thing normally handled? I have simple forms that
have obvious attribures but this feels different somehow.

thoughts?
-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: a Form with different actions actions

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
DispatchAction sounds like the right answer here, but remember that good
design generally dictates that the shorted a class is, the better. 
Therefore, you most likely want to have your DispatchAction do not much
more than make use of some helper class to do the actual functionality. 
Aside from keeping the DispatchActions small, it is better separation of
responsibilities too.

One other way to do this is to alter the action of your form on the client
via scripting.  For instance, attach this to your graph button:

<html:button onClick="myForm.action='graphAction.do';" />

You can attach that same onClick event handler to any form element you
want, setting the appropriate action mapping.

Not sure either is really better, but its another way.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Fri, April 15, 2005 11:52 am, David Johnson said:
> question:
>
> Does this tip apply to the latest version of Struts? I'm using V1.2.4
> and I notived this tip references the "perform()" method which as far
> as I know is deprecated.
>
> I implemented this as it recommends, setting parameter="dispatch" in
> the ActionMapping, but the methods I've created (with the same
> signature as the execute() method arent being called,
>
> for example: my "report" submit button html is now
>
> <html:submit property="runReportFlag" onclick="set('report');">Run
> Report</html:submit>
>
> but the "report" method isnt being called....
>
> what did I miss? Ted?
>
>
> On 4/15/05, David Johnson <ch...@gmail.com> wrote:
>> GREAT solution!!! Thank you both very much, and of course thanks to
>> Ted H as well!
>>
>> -D
>>
>> On 4/15/05, Rafael Taboada <ka...@gmail.com> wrote:
>> > Hi. U can use DispatchAction class to have different methods for each
>> > function u have in ur form.
>> >
>> > For different buttons, there is a possibility to use
>> > LookupDispatchAction class. Don't forget to map the keys.
>> >
>> > On 4/15/05, David Johnson <ch...@gmail.com> wrote:
>> > > All
>> > >
>> > > I have a large page with a form on it that I need to submit to
>> > > diffferent actions depending on that the user clicks.
>> > >
>> > > For example, I have on this page
>> > >
>> > > 0. a list of items the user can select 1-->n of (using checkboxes)
>> > > 1. a list of graph types, with a "graph chosen now" button (user
>> > > chooses things from item #0 above)
>> > > 2. a list of reports, with a "report chosen now" button (user
>> chooses
>> > > things from item #0 above)
>> > > 3. a "combine selected" buttons (again user chooses things from item
>> #0 above)
>> > > 4. a "create new" button
>> > >
>> > > Essentially I may need to access some or ALL of the form fields seen
>> > > on the page regardless of which path the user takes, so I assume
>> that
>> > > means one big form.
>> > >
>> > > the problem is I want to submit to "graphAction" for graphs or
>> > > "reportAction" for reports or "combineAction" etc.
>> > >
>> > > how is this kind of thing normally handled? I have simple forms that
>> > > have obvious attribures but this feels different somehow.
>> > >
>> > > thoughts?
>> > > --
>> > > -Dave
>> > > ChaChaNY@Gmail.com
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > > For additional commands, e-mail: user-help@struts.apache.org
>> > >
>> > >
>> >
>> > --
>> >
>> > Rafael Taboada
>> >
>>
>> --
>> -Dave
>> ChaChaNY@Gmail.com
>>
>
>
> --
> -Dave
> ChaChaNY@Gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: a Form with different actions actions

Posted by David Johnson <ch...@gmail.com>.
question:

Does this tip apply to the latest version of Struts? I'm using V1.2.4
and I notived this tip references the "perform()" method which as far
as I know is deprecated.

I implemented this as it recommends, setting parameter="dispatch" in
the ActionMapping, but the methods I've created (with the same
signature as the execute() method arent being called,

for example: my "report" submit button html is now

<html:submit property="runReportFlag" onclick="set('report');">Run
Report</html:submit>

but the "report" method isnt being called....

what did I miss? Ted?


On 4/15/05, David Johnson <ch...@gmail.com> wrote:
> GREAT solution!!! Thank you both very much, and of course thanks to
> Ted H as well!
> 
> -D
> 
> On 4/15/05, Rafael Taboada <ka...@gmail.com> wrote:
> > Hi. U can use DispatchAction class to have different methods for each
> > function u have in ur form.
> >
> > For different buttons, there is a possibility to use
> > LookupDispatchAction class. Don't forget to map the keys.
> >
> > On 4/15/05, David Johnson <ch...@gmail.com> wrote:
> > > All
> > >
> > > I have a large page with a form on it that I need to submit to
> > > diffferent actions depending on that the user clicks.
> > >
> > > For example, I have on this page
> > >
> > > 0. a list of items the user can select 1-->n of (using checkboxes)
> > > 1. a list of graph types, with a "graph chosen now" button (user
> > > chooses things from item #0 above)
> > > 2. a list of reports, with a "report chosen now" button (user chooses
> > > things from item #0 above)
> > > 3. a "combine selected" buttons (again user chooses things from item #0 above)
> > > 4. a "create new" button
> > >
> > > Essentially I may need to access some or ALL of the form fields seen
> > > on the page regardless of which path the user takes, so I assume that
> > > means one big form.
> > >
> > > the problem is I want to submit to "graphAction" for graphs or
> > > "reportAction" for reports or "combineAction" etc.
> > >
> > > how is this kind of thing normally handled? I have simple forms that
> > > have obvious attribures but this feels different somehow.
> > >
> > > thoughts?
> > > --
> > > -Dave
> > > ChaChaNY@Gmail.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > --
> >
> > Rafael Taboada
> >
> 
> --
> -Dave
> ChaChaNY@Gmail.com
> 


-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: a Form with different actions actions

Posted by David Johnson <ch...@gmail.com>.
GREAT solution!!! Thank you both very much, and of course thanks to
Ted H as well!

-D

On 4/15/05, Rafael Taboada <ka...@gmail.com> wrote:
> Hi. U can use DispatchAction class to have different methods for each
> function u have in ur form.
> 
> For different buttons, there is a possibility to use
> LookupDispatchAction class. Don't forget to map the keys.
> 
> On 4/15/05, David Johnson <ch...@gmail.com> wrote:
> > All
> >
> > I have a large page with a form on it that I need to submit to
> > diffferent actions depending on that the user clicks.
> >
> > For example, I have on this page
> >
> > 0. a list of items the user can select 1-->n of (using checkboxes)
> > 1. a list of graph types, with a "graph chosen now" button (user
> > chooses things from item #0 above)
> > 2. a list of reports, with a "report chosen now" button (user chooses
> > things from item #0 above)
> > 3. a "combine selected" buttons (again user chooses things from item #0 above)
> > 4. a "create new" button
> >
> > Essentially I may need to access some or ALL of the form fields seen
> > on the page regardless of which path the user takes, so I assume that
> > means one big form.
> >
> > the problem is I want to submit to "graphAction" for graphs or
> > "reportAction" for reports or "combineAction" etc.
> >
> > how is this kind of thing normally handled? I have simple forms that
> > have obvious attribures but this feels different somehow.
> >
> > thoughts?
> > --
> > -Dave
> > ChaChaNY@Gmail.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> --
> 
> Rafael Taboada
> 


-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: a Form with different actions actions

Posted by Rafael Taboada <ka...@gmail.com>.
 Hi. U can use DispatchAction class to have different methods for each
function u have in ur form.

 For different buttons, there is a possibility to use
LookupDispatchAction class. Don't forget to map the keys.

On 4/15/05, David Johnson <ch...@gmail.com> wrote:
> All
> 
> I have a large page with a form on it that I need to submit to
> diffferent actions depending on that the user clicks.
> 
> For example, I have on this page
> 
> 0. a list of items the user can select 1-->n of (using checkboxes)
> 1. a list of graph types, with a "graph chosen now" button (user
> chooses things from item #0 above)
> 2. a list of reports, with a "report chosen now" button (user chooses
> things from item #0 above)
> 3. a "combine selected" buttons (again user chooses things from item #0 above)
> 4. a "create new" button
> 
> Essentially I may need to access some or ALL of the form fields seen
> on the page regardless of which path the user takes, so I assume that
> means one big form.
> 
> the problem is I want to submit to "graphAction" for graphs or
> "reportAction" for reports or "combineAction" etc.
> 
> how is this kind of thing normally handled? I have simple forms that
> have obvious attribures but this feels different somehow.
> 
> thoughts?
> --
> -Dave
> ChaChaNY@Gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 

 Rafael Taboada

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: a Form with different actions actions

Posted by DG...@EvergreenInvestments.com.
In the past, I've used DispatchAction to accomplish this: 
http://husted.com/struts/tips/002.html

I'm not sure if there is a newer/better way.

Dennis


David Johnson <ch...@gmail.com> 
04/15/2005 09:37 AM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
Struts Users Mailing List <us...@struts.apache.org>
cc

Subject
a Form with different actions actions






All

I have a large page with a form on it that I need to submit to
diffferent actions depending on that the user clicks.

For example, I have on this page

0. a list of items the user can select 1-->n of (using checkboxes)
1. a list of graph types, with a "graph chosen now" button (user
chooses things from item #0 above)
2. a list of reports, with a "report chosen now" button (user chooses
things from item #0 above)
3. a "combine selected" buttons (again user chooses things from item #0 
above)
4. a "create new" button

Essentially I may need to access some or ALL of the form fields seen
on the page regardless of which path the user takes, so I assume that
means one big form.

the problem is I want to submit to "graphAction" for graphs or
"reportAction" for reports or "combineAction" etc.

how is this kind of thing normally handled? I have simple forms that
have obvious attribures but this feels different somehow.

thoughts?
-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org