Visualizing data with tree

The tree component visualizes hierarchical data in tree format.

How to do it...

The data for the tree is provided with instances of org.primefaces.model.TreeNode, which correspond to the nodes in the tree. A pure client-side tree might be useful to create tree-based navigation menus. A basic data model for a tree could be constructed as follows:

TreeNode root = new DefaultTreeNode("Root", null); TreeNode node1 = new DefaultTreeNode("Node1", root); TreeNode node2 = new DefaultTreeNode("Node2", root); TreeNode node11 = new DefaultTreeNode("Node1.1", node1); TreeNode node12 = new DefaultTreeNode("Node1.2", node1); TreeNode node21 = new DefaultTreeNode("Node2.1", node2); TreeNode node211 = new DefaultTreeNode("Node2.1.1", ...

Get PrimeFaces Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.