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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing value with multiple actions in same form

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am new to JSP/Struts. I really need your help on how to pass values in a form with multiple actions. Please help out.

Here is the sample code.
<html:form action="someAction" method="post">
<table>
<tr>
<td><html:select property="factoryId">
<html:option...>
</td>
</tr>
<tr><td><html:link page="/actions/../actionOne.do"></td></tr>
<tr><td><html:link page="/actions/../actionTwo.do"></td></tr>
</table>
</html:form>

My question: how to pass factoryId to servlet (Struts action)?
Many thanks.
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

You should open this topic in the Struts forum.

If you are using Struts 1.x, you need to use struts 'form's. If you are using Struts 2, you can make a factoryId instance variable in the action class and it will be populated.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
For multiple actions, usually, in Struts, you have to do an extra effort to handle multiple actions in one form.

For example, you have 2 buttons, say, one to Save and another to Delete. You can put onClick javascript function on both buttons. Both will call the same javascript function when clicked, for example processClick(). However, they will pass a parameter. Save will call processClick('save'), and Delete will call processClick('delete').

Inside processClick, it will be like:

processClick(clicked){
if (clicked=='save'){
....forms[0].action='/asdf/asdf/save.do';}
else{
....forms[0].action='/asdf/asdf/delete.do';}

....forms[0].submit;
}
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.
    Bookmark Topic Watch Topic
  • New Topic