Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accesing value from list of string

 
ekansh singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all
I am new to struts 2.
I am having List of string in action classs
List<String> categories

this class has getter and setters

now there is a guide.jsp

<s:iterator value="categories">

<tr>
<td>

<s:url id="categoryInformation" action="ShowCategoryInformation.action">
<s:param name="categoryName" value ="" />
</s:url>
<s:a href="%{categoryInformation}">
<s:property/>
</s:a>
</td>

</tr>
</s:iterator>

i know how to display the value stored in the list .. i mean i can use this <s:property/>
but here I want to make the url

<s:url id="categoryInformation" action="ShowCategoryInformation.action">
<s:param name="categoryName" value ="" />
</s:url>

and this VALUE in <s:param name="categoryName" value ="" /> >

should be the the string present in th list..
can you please tell me how to get each string value from the list the value attribute of Param tag
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the iterator tag's "id" (S2.0) or "var" (S2.1) attribute to hold each object of iteration then refer to it in the param tag:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic