Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 iterator tag

 
Vijay Ramakrishnan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s:iterator value="countries">
<s:iterator value="cities">
<s:property value="name"/>, <s:property value="[1].name"/><br>
</s:iterator>

This will display

Wellington, New Zealand
Auckland, New Zealand
Moscow, Russia
Glasgow, Scotland
Edinburgh, Scotland
Stockholm, Sweden


I want to display

New Zealand
-----------
Wellington
Auckland

Russia
------

Moscow

Scotland
--------

Glasgow
Edinburgh ..

Is it possible with the iterator tag?
etc ..
 
Tomasz Sobal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's possible, just get value from first iterator before the inner one starts:


Next thing to do is to pack it in some table/div container so it displays nicely
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or else you can send a map object having countries name as key and cities as list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic