File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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?

<b>Luciano Queiroz</b><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>
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...
Berny Woehrlin
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 782

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


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.

---<br />Time flies like an arrow,<br />Fruit flies like a banana
I agree. Here's the link:
subject: Actions in Struts
It's not a secret anymore!