PDA

View Full Version : Display tree on JSP, recursion?



pak
Sep 7th, 2004, 04:54 AM
Hi there

I have a "tree" structure of Node objects, each containing a List of children Node objects etc.

I pass the root Node object to a JSP, and would like to display the tree structure.

How do I display this on a JSP? For example, can I recurse with jstl or spring tags?

Thanks for any help,
Peter

Alef Arendsen
Sep 14th, 2004, 01:57 PM
You could recurse using JSTL <c:forEach> tags. I suggest you have a look at JSP 2.0 tagfiles, I think they provide a flexible and easy to test wya to do what you want (recursively including JSPs, etcetera).

Alef

http://www.onjava.com/pub/a/onjava/2003/11/05/jsp.html

Ilya Boyandin
Nov 22nd, 2007, 03:47 AM
This JSP includes itself recursively:


1. ${node.title}
2. <div class="children">
3. <c:foreach var="node" items="${node.children}">
4. <c:set var="node" value="${node}" scope="request"/>
5. <jsp:include page="node.jsp"/>
6. </c:foreach>
7. </div>

Here (http://blog.boyandi.net/?p=11) is a short explanation.

oracsa
Jul 9th, 2011, 02:20 AM
Google for tree4jsp. The tag looks easily integrable with spring applications, and also provides fairly good tree UI.