Hello all, and thank you in advance. I'm relatively new to struts 2, as I started working with the framework about 6 months ago on a part time basis. I'm struggling to solve a problem that I would think would be fairly common: displaying a tree within a JSP.
Essentially, I have an object (let's call it "Item") that looks something like the following: class Item { private String name; private Set<Item> children; // getters and setters } Working within a JSP page, I want to display the data within this Item as follows: <ul> <li> <s:property value="item.name"/> <s:iterator value="item.children" var="child"> <ul> <li> <s:property value="child.name"/> <s:iterator value="child.children" var="grandchild"> <ul> <li> <s:property value="grandchild.name"/> <s:iterator value="grandchild.child" var "greatgrandchild"> ... and so on </s:iterator> </li> </ul> </s:iterator> </li> </ul> </s:iterator> </li> </ul> Ideally, I would be able to display this data using some sort of recursion, since there's really no way to tell how deep this tree is. If anyone knows of a good solution to this problem, I'd be very interested in hearing it. I did come up with what I thought might be a solution using the <s:include> tag. I came up with the following: In the main jsp page, I have: <ul> <li> <s:include value="inc/displayItem.jsp"> <s:param name="item" value="item"/> </s:include> </li> </ul> In the included jsp page, I have: <s:property value="item.name"/> <s:iterator value="item.children" var="child"> <ul> <li> <s:include value="inc/displayItem.jsp"> <s:param name="item" value="child"/> </s:include> </li> </ul> </s:iterator> This does not work, of course, because a parameter from within an included jsp page can only be referenced like this: {$param.item}. In addition, I can't use that method to access the included parameter within any struts 2 tags (as far as I can tell). So again, I suppose my question is: is this an appropriate way of solving this problem? If so, how can I get this all to work? If not, what's a better way of going about this? Thanks again for all of your help, Anthony Frasso a...@cornell.edu --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org