aspose file tools
The moose likes JSP and the fly likes Passing value with multiple actions in same form Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Passing value with multiple actions in same form

Nepean Robert
Greenhorn

Joined: Dec 13, 2008
Posts: 3
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
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
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;
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56157
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing value with multiple actions in same form
 
Similar Threads
can we replace submit button with link in order to submit form ?
Cannot retrieve mapping for action /content/AddLinks
hml:link
doesnt display struts tags in normal html form
Passing values in a form with multiple actions