File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes multiple actions for one html:form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multiple actions for one html:form" Watch "multiple actions for one html:form" New topic

multiple actions for one html:form

David Cox

Joined: Mar 22, 2005
Posts: 15
I would like to associate different actions to one <html:form>, depending which submitButton was clicked on.

For example five submit buttons in one <html:form> and each submit button activates a different Action.Anybody know a good solution?.
[ March 22, 2005: Message edited by: David Cox ]
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

It is a common solution to put more than one execute-style method in a DispatchAction. The DispatchAction which will determine which execute-style method call. Now, it IS possible to make the buttons each go to a different Action entirely but you'd have to use Javascript >blech!< or some other crazy trick - so IMO it is much simpler to use a DispatchAction of some sort.

LookupDispatchAction and MappingDispatchAction both extend DispatchAction and come packaged with the Struts framework.

CommandDispatchAction is my rewrite of the DispatchAction and comes packaged with free technical support.

A good workman is known by his tools.
I agree. Here's the link:
subject: multiple actions for one html:form
jQuery in Action, 3rd edition