Time for action – creating a Tree component
Let us see how we can use a Tree component to display PostTitle in a tree structure.
- Initialize the root
TreeNode
component and add child nodes.public class TreeController { private TreeNode root; public TreeController() { root = new DefaultTreeNode("Root", null); TreeNode node2013 = new DefaultTreeNode("2013", root); TreeNode node2012 = new DefaultTreeNode("2012", root); TreeNode node2011 = new DefaultTreeNode("2011", root); TreeNode jan2013 = new DefaultTreeNode("Jan", node2013); TreeNode feb2013 = new DefaultTreeNode("Feb", node2013); TreeNode aug2012 = new DefaultTreeNode("Aug", node2012); TreeNode sep2012 = new DefaultTreeNode("Sep", node2012); TreeNode nov2011 = new DefaultTreeNode("Nov", node2011); TreeNode jan2013Post1 = new DefaultTreeNode("PrimeFaces Elite...