Announcement Announcement Module
Collapse
No announcement yet.
Display tree on JSP, recursion? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display tree on JSP, recursion?

    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

  • #2
    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

    Comment


    • #3
      This JSP includes itself recursively:
      Code:
         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 is a short explanation.
      Last edited by Ilya Boyandin; Nov 22nd, 2007, 04:51 AM.

      Comment


      • #4
        probably you can try to use tree4jsp in your spring application.

        Google for tree4jsp. The tag looks easily integrable with spring applications, and also provides fairly good tree UI.

        Comment

        Working...
        X