public class Tree extends TreeFamily implements javax.faces.component.NamingContainer
UIComponent
that supports data binding to a tree of data objects represented by
a TreeModel
instance, which is the current value of this component itself (typically established via a
ValueExpression
). During iterative processing over the nodes of tree in the tree model, the object for the
current node is exposed as a request attribute under the key specified by the var
attribute. The node
itself is exposed as a request attribute under the key specified by the varNode
attribute.
Only children of type TreeNode
are allowed and processed by this component.
This component does not have a renderer since it does not render any markup by itself. This allows the developers to have full control over the markup of the tree by declaring the appropriate JSF components or HTML elements in the markup. Here is a basic usage example:
<o:tree value="#{bean.treeModel}" var="item" varNode="node"> <o:treeNode> <ul> <o:treeNodeItem> <li> #{node.index} #{item.someProperty} <o:treeInsertChildren /> </li> </o:treeNodeItem> </ul> </o:treeNode> </o:tree>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILY
Constructor and Description |
---|
Tree() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContainerClientId(javax.faces.context.FacesContext context)
An override which appends the index of the current model node to the client ID chain, if any available.
|
protected TreeModel |
getCurrentModelNode()
Returns the current node of the tree model.
|
java.lang.Object |
getValue()
Returns the tree model.
|
java.lang.String |
getVar()
Returns the name of the request attribute which exposes the wrapped data of the current node of the tree model.
|
java.lang.String |
getVarNode()
Returns the name of the request attribute which exposes the current node of the tree model.
|
protected void |
process(javax.faces.context.FacesContext context,
javax.faces.event.PhaseId phaseId)
Set the root node and delegate the call to
processTreeNode(FacesContext, PhaseId) . |
protected void |
processTreeNode(javax.faces.context.FacesContext context,
javax.faces.event.PhaseId phaseId)
If the current model node isn't a leaf (i.e.
|
protected void |
setCurrentModelNode(javax.faces.context.FacesContext context,
TreeModel currentModelNode)
Sets the current node of the tree model.
|
void |
setValue(java.lang.Object value)
Sets the tree model.
|
void |
setValueExpression(java.lang.String name,
javax.el.ValueExpression binding)
An override which checks if this isn't been invoked on
var or varNode attribute. |
void |
setVar(java.lang.String var)
Sets the name of the request attribute which exposes the wrapped data of the current node of the tree model.
|
void |
setVarNode(java.lang.String varNode)
Sets the name of the request attribute which exposes the current node of the tree model.
|
protected void |
validateHierarchy()
Validate the component hierarchy.
|
boolean |
visitTree(javax.faces.component.visit.VisitContext context,
javax.faces.component.visit.VisitCallback callback)
Set the root node and delegate the call to
visitTreeNode(VisitContext, VisitCallback) . |
protected boolean |
visitTreeNode(javax.faces.component.visit.VisitContext context,
javax.faces.component.visit.VisitCallback callback)
If the current model node isn't a leaf (i.e.
|
encodeChildren, getFamily, getRendersChildren, processDecodes, processSuper, processUpdates, processValidators
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
encodeAll, getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, subscribeToEvent, unsubscribeFromEvent
public static final java.lang.String COMPONENT_TYPE
public java.lang.String getContainerClientId(javax.faces.context.FacesContext context)
getContainerClientId
in class javax.faces.component.UIComponent
TreeModel.getIndex()
public void setValueExpression(java.lang.String name, javax.el.ValueExpression binding)
var
or varNode
attribute.
Finally it delegates to the super method.setValueExpression
in class javax.faces.component.UIComponent
java.lang.IllegalArgumentException
- When this value expression is been set on var
or
varNode
attribute.protected void validateHierarchy()
validateHierarchy
in class TreeFamily
java.lang.IllegalArgumentException
- When this component is nested in another Tree
, or when there aren't any
children of type TreeNode
.protected void process(javax.faces.context.FacesContext context, javax.faces.event.PhaseId phaseId)
processTreeNode(FacesContext, PhaseId)
.process
in class TreeFamily
context
- The faces context to work with.phaseId
- The current phase ID.public boolean visitTree(javax.faces.component.visit.VisitContext context, javax.faces.component.visit.VisitCallback callback)
visitTreeNode(VisitContext, VisitCallback)
.visitTree
in class javax.faces.component.UIComponent
context
- The visit context to work with.callback
- The visit callback to work with.protected void processTreeNode(javax.faces.context.FacesContext context, javax.faces.event.PhaseId phaseId)
TreeNode
associated
with the level of the current model node. If it isn't null, then process it according to the rules of the given
phase ID. This method is also called by TreeInsertChildren.process(FacesContext, PhaseId)
.context
- The faces context to work with.phaseId
- The current phase ID.TreeModel.isLeaf()
,
TreeModel.getLevel()
,
TreeInsertChildren
protected boolean visitTreeNode(javax.faces.component.visit.VisitContext context, javax.faces.component.visit.VisitCallback callback)
TreeNode
associated
with the level of the current model node. If it isn't null, then visit it according to the given visit context
and callback. This method is also called by TreeInsertChildren.visitTree(VisitContext, VisitCallback)
.context
- The visit context to work with.callback
- The visit callback to work with.TreeModel.isLeaf()
,
TreeModel.getLevel()
,
TreeInsertChildren
protected void setCurrentModelNode(javax.faces.context.FacesContext context, TreeModel currentModelNode)
var
attribute, if any. The node itself will also be set as request attribute associated with the
varNode
attribute, if any.context
- The faces context to work with.currentModelNode
- The current node of the tree model.protected TreeModel getCurrentModelNode()
public java.lang.Object getValue()
public void setValue(java.lang.Object value)
value
- The tree model.public java.lang.String getVar()
public void setVar(java.lang.String var)
var
- The name of the request attribute which exposes the wrapped data of the current node of the tree
model.public java.lang.String getVarNode()
public void setVarNode(java.lang.String varNode)
varNode
- The name of the request attribute which exposes the current node of the tree model.