• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Multiple Submit Buttons?

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would I do the first method?
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic