aspose file tools*
The moose likes Struts and the fly likes Multiple Submit Buttons? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple Submit Buttons?" Watch "Multiple Submit Buttons?" New topic
Author

Multiple Submit Buttons?

Bloo Barton
Ranch Hand

Joined: May 09, 2005
Posts: 63
I would like to submit a form that has multiple submit buttons. For each button I would like to send a different action.

How can I dynamically populate the action parameter to my form when doing this?

<html:form action="???">

<%-- Submit Buttons --%>
<html:submit property="Confirm"><fmt:message key="label.confirm"/></html:submit>

<html:submit property="Re-enter"><fmt:message key="label.reenter"/></html:submit>

<html:submit property="Logout"><fmt:message key="label.logout"/></html:submit>

<%-- Etc... --%>
</html:form>
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Hi,

You can do this in two ways... One by writing different actions to the buttons and calling them onclick or write the different actions as different method in a single DispatchAction class and calling different method on different button clicks.
Bloo Barton
Ranch Hand

Joined: May 09, 2005
Posts: 63
How would I do the first method?
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Write to action classes and two action mappings in struts-config file with the same actionform.

In the jsp add the below javascript on onClick event

function formAction() {
document.form.action="aaa.do"
document.form.submit();
}

Srilakshmi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Submit Buttons?