aspose file tools*
The moose likes Struts and the fly likes Passing values in a form with multiple actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing values in a form with multiple actions" Watch "Passing values in a form with multiple actions" New topic
Author

Passing values in a form with multiple actions

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">
<html ption...>
</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.
Nepean Robert
Greenhorn

Joined: Dec 13, 2008
Posts: 3
I kind of thinking how to pass parameters in html:link tag.
I defined a HashMap first, then pass the params map to the link tag.
<% HashMap params = new HashMap();
params.put( "factoryId", "120" );
request.setAttribute( "params", params );
%>

JSP code,
<html:link page="/actions/../someAction.do" name="params">
</html:link>.

You see I hardcode 120 to the factoryId. factoryId is drop done list, I don't know how to define the factoryId.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you want to dynamically create a link based on the value in a form element you need to use JavaScript.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing values in a form with multiple actions
 
Similar Threads
Accessing struts form value in JSP
Passing value with multiple actions in same form
doesnt display struts tags in normal html form
Cannot retrieve mapping for action /content/AddLinks
can we replace submit button with link in order to submit form ?