aspose file tools*
The moose likes Struts and the fly likes Actions in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Actions in Struts" Watch "Actions in Struts" New topic
Author

Actions in Struts

Luciano Queiroz
Ranch Hand

Joined: Feb 04, 2002
Posts: 172
How can I call more than one Action from a HTML form?
For example, I have 3 buttons in my form: insert, delete and update. Is there any way I can use a parameter in each submit to call different Actions?
Thanks!


<b>Luciano Queiroz</b><br/>
 Brazil<br/>
 <i>SCJP 1.2, SCWCD, IBM 141, IBM 483, SCJP 1.4, IBM 484, IBM 287, SCBCD, SCEA, SCJP 5.0, SCJP 6.0, SCWCD 5</i>
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Luciano,
as far as I do understand your question I would use just one Action containing a little logic to learn from the client what to do: delete, update or create. An alternative could be to create three different Actions called by three different forms on the client side.
Just my $0,02...
Regards
Berny Woehrlin
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Read up on the DispatchAction and LookupDispatchAction on Ted Husted's Struts Tips website.
Struts tips


Regards,

Pho
Jesse Beaumont
Ranch Hand

Joined: May 30, 2002
Posts: 43
The way we do it is we dynamically rewrite the form's action attribute depending on which button was pressed and then post to a different action-mapping.
Using DispatchAction is a cleaner way of doing the same thing.
Jesse


---<br />Time flies like an arrow,<br />Fruit flies like a banana
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Actions in Struts