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"> <htmlption...> </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.
Jesus Angeles
Ranch Hand
Joined: Feb 26, 2005
Posts: 2036
posted
0
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
Joined: Feb 26, 2005
Posts: 2036
posted
0
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';}
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.