Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Submit Buttons?

 
Bloo Barton
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I do the first method?
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic