File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 2049
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: 2049
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: 60785
    
  65

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.


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