Reputation: 20356
On one page I have a list of Destinations (read cities). When I click on one, I need to navigate to an action/result pair that would spit out the Destination details.
(I'm using struts 2)
Menu.jsp:
<s:iterator value="destinations">
<li> <s:property value="name" /> </li>
</s:iterator>
where destinations is a Set in MenuAction.java.
Destination.jsp
Name: <s:property value="destination.name" />
where destination is a property in DestinationAction.java.
How do I wrap the destinations on Menu.jsp so that I can pass on the Destination
object from Menu.jsp to DestinationActio
n ?
Upvotes: 0
Views: 304
Reputation: 20356
From Umesh's comments, this is what I ended up using:
<ul>
<s:iterator value="destinations">
<li>
<s:url action="Destination" var="urlTag">
<s:param name="id"> <s:property value="id" /> </s:param>
</s:url>
<a href="<s:property value="#urlTag" />" >
<s:property value="name" />
</a>
</li>
</s:iterator>
</ul>
Upvotes: 1
Reputation: 3424
Instead of passing the destination
object from JSP to Action, pass only the name
property ( and other properties according to your need). In Menu.jsp
use links like this:
<s:iterator value="destinations">
<li>
<a href='DestinationAction.action?destination.name=<s:property value="name" />' >
<s:property value="name" />
</a>
</li>
</s:iterator>
Upvotes: 0