This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes struts 2 iterator tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 iterator tag " Watch "struts 2 iterator tag " New topic

struts 2 iterator tag

Vijay Ramakrishnan

Joined: Oct 22, 2011
Posts: 1
s:iterator value="countries">
<s:iterator value="cities">
<s:property value="name"/>, <s:property value="[1].name"/><br>

This will display

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

I want to display

New Zealand




Edinburgh ..

Is it possible with the iterator tag?
etc ..
Tomasz Sobal

Joined: Oct 25, 2011
Posts: 3
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

Joined: Aug 01, 2007
Posts: 485

Or else you can send a map object having countries name as key and cities as list.

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
I agree. Here's the link:
subject: struts 2 iterator tag
Similar Threads
Struts 2 iterators
Struts2 Iteator Tag with object in object
Loop in JSP with Struts
s:iterator question
iterate doubt