File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Issue in using <s:iterator /> within another <s:iterator /> 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 "Issue in using <s:iterator /> within another <s:iterator /> " Watch "Issue in using <s:iterator /> within another <s:iterator /> " New topic

Issue in using <s:iterator /> within another <s:iterator />

camp jay

Joined: Jun 17, 2009
Posts: 4

I'm iterating object<HOUSE> list in JSP.

And in this HOUSE object I have another object<ROOMS> list. I need to iterate Room list within House list iterator and need to access HOUSE properties also within Room iterator.


Can you tell me how to access properties of two objects separately in inner iterator?
I guess there might be better approach to this.

David Newton

Joined: Sep 29, 2008
Posts: 12617

You can't nest custom tags like that.

The correct course of action is to use the "var" attribute (or "id", depending on which version of Struts 2 you're using) to capture each object being iterated over in both loops.
It is sorta covered in the JavaRanch Style Guide.
subject: Issue in using <s:iterator /> within another <s:iterator />
Similar Threads
lists inside a list :(((
Struts 2 - Problem updating textfields created by iterating over a list of objects
Struts2 - <s:iterator> in two-Dimensional Array.
about lists
Sticky nested lists problem in Struts 2