The UITree Component Class

The com.mycompany.jsf.component.UITree class is the implementation of the tree component. It’s quite similar to the standard UIData component. It uses a set of component instances defined as facets to render all objects in the model. It repeatedly calls the setNodeId() method as it traverses the tree in all request processing lifecycle phases and exposes the current node through a request scope variable, and then asks the appropriate facet for the current node to process it. The main difference is that the UITree component works with a tree structure model, while UIData works with a model of rows and columns.

The first part of the class should look familiar from the previous section:

package com.mycompany.jsf.component; import java.io.IOException; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.component.EditableValueHolder; import javax.faces.component.NamingContainer; import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.el.ValueBinding; import javax.faces.event.AbortProcessingException; import javax.faces.event.FacesEvent; import javax.faces.event.FacesListener; import javax.faces.event.PhaseId; import com.mycompany.jsf.model.TreeNode; import com.mycompany.jsf.model.TreeModel; public class UITree extends UIComponentBase ...

Get JavaServer Faces now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.