I need to display tree on JSP page. How can I do that? I have following object:
public class Node {
private Long id;
private Long parentId;
private String name;
private List<Node> children;
// Getters & setters
}
Roll your own with jsp recursion
In Controller.java
Node root = getTreeRootNode();
request.setAttribute("node", root);
In main.jsp
page
<jsp:include page="node.jsp"/>
In node.jsp
<c:forEach var="node" items="${node.children}">
<!-- TODO: print the node here -->
<c:set var="node" value="${node}" scope="request"/>
<jsp:include page="node.jsp"/>
</c:forEach>
Based on http://web.archive.org/web/20130509135219/http://blog.boyandi.net/2007/11/21/jsp-recursion/
You may want to try http://www.soft82.com/download/windows/tree4jsp/
It is also downloadable from http://www.einnovates.com/jsptools/tree4jsp/tree4jsp_v1.2.zip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With