File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
It's not a secret anymore!