public class Tree extends TreeFamily implements NamingContainer
The <o:tree> allows the developers to have full control over the markup of a tree
hierarchy by declaring the appropriate JSF components or HTML elements in the markup. The <o:tree>
does namely not render any HTML markup by itself.
The component value must point to a tree of data objects represented by a TreeModel instance, 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.
The <o:tree> tag supports only child tags of type <o:treeNode>, representing
parent tree nodes. There can be multiple <o:treeNode> tags, each representing a separate parent
tree node level, so that different markup could be declared for each tree node level, if necessary. The
<o:treeNode> tag in turn supports child tag <o:treeNodeItem> which represents
each child of the current parent tree node. The <o:treeNodeItem> in turn supports child tag
<o:treeInsertChildren> which represents the insertion point of the grand children.
Here is a basic usage example where each parent tree node level is treated the same way via a single
<o:treeNode>:
<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>
The <o:treeNode> represents the parent tree node. Within this component, the var
attribute of the <o:tree> will expose the parent tree node. Each of its children is processed by
<o:treeNodeItem> on which the var attribute of the <o:tree> in
turn exposes each child of the parent tree node.
The optional level attribute can be used to specify for which tree node level as obtained by
TreeModel.getLevel() the <o:treeNode> should be rendered. The root tree node has level 0.
If the level attribute is unspecified, then the <o:treeNode> will be rendered for any
tree node level which hasn't already a <o:treeNode level="x"> specified.
The <o:treeNodeItem> represents the child item of the parent tree note as represented by
<o:treeNode>. Within this component, the var attribute of the parent
<o:tree> component will expose the child tree node.
Within <o:treeNodeItem> you can use <o:treeInsertChildren> to declare the
place where to recursively render the <o:treeNode> whereby the current child item is in turn
interpreted as a parent tree node (i.e. where you'd like to insert the grand-children).
The <o:treeInsertChildren> represents the insertion point for the grand children. This is in turn
further interpreted as <o:treeNode>.
TreeNode,
TreeNodeItem,
TreeInsertChildren,
TreeFamily,
TreeModel,
AbstractTreeModel,
ListTreeModel,
SortedTreeModel| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILYATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEYSEPARATOR_CHAR| Constructor and Description |
|---|
Tree() |
| Modifier and Type | Method and Description |
|---|---|
void |
broadcast(FacesEvent event)
If the given event is an instance of the specific faces event which was created during our
queueEvent(FacesEvent), then extract the node from it and set it as current node and delegate the call
to the wrapped faces event. |
String |
getContainerClientId(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.
|
Object |
getValue()
Returns the tree model.
|
String |
getVar()
Returns the name of the request attribute which exposes the wrapped data of the current node of the tree model.
|
String |
getVarNode()
Returns the name of the request attribute which exposes the current node of the tree model.
|
protected boolean |
isVisitable(VisitContext context) |
protected void |
process(FacesContext context,
PhaseId phaseId)
Set the root node as current node and delegate the call to
processTreeNode(FacesContext, PhaseId). |
protected void |
processTreeNode(FacesContext context,
PhaseId phaseId)
If the current model node isn't a leaf (i.e.
|
void |
queueEvent(FacesEvent event)
An override which wraps the given faces event in a specific faces event which remembers the current model node.
|
protected void |
setCurrentModelNode(FacesContext context,
TreeModel currentModelNode)
Sets the current node of the tree model.
|
void |
setValue(Object value)
Sets the tree model.
|
void |
setValueExpression(String name,
ValueExpression binding)
An override which checks if this isn't been invoked on
var or varNode attribute. |
void |
setVar(String var)
Sets the name of the request attribute which exposes the wrapped data of the current node of the tree model.
|
void |
setVarNode(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(VisitContext context,
VisitCallback callback)
Set the root node as current node and delegate the call to
visitTreeNode(VisitContext, VisitCallback). |
protected boolean |
visitTreeNode(VisitContext context,
VisitCallback callback)
If the current model node isn't a leaf (i.e.
|
encodeChildren, getFamily, getRendersChildren, processDecodes, processSuper, processUpdates, processValidatorsaddClientBehavior, addFacesListener, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEventencodeAll, getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInViewpublic static final String COMPONENT_TYPE
public String getContainerClientId(FacesContext context)
getContainerClientId in class UIComponentTreeModel.getIndex()public void setValueExpression(String name, ValueExpression binding)
var or varNode attribute.
Finally it delegates to the super method.setValueExpression in class UIComponentIllegalArgumentException - When this value expression is been set on var or
varNode attribute.public void queueEvent(FacesEvent event)
queueEvent in class UIComponentBaseprotected void validateHierarchy()
validateHierarchy in class TreeFamilyIllegalStateException - When this component is nested in another Tree, or when there aren't any
children of type TreeNode.protected void process(FacesContext context, PhaseId phaseId)
processTreeNode(FacesContext, PhaseId).process in class TreeFamilycontext - The faces context to work with.phaseId - The current phase ID.public boolean visitTree(VisitContext context, VisitCallback callback)
visitTreeNode(VisitContext, VisitCallback).visitTree in class UIComponentcontext - The visit context to work with.callback - The visit callback to work with.protected boolean isVisitable(VisitContext context)
isVisitable in class UIComponentpublic void broadcast(FacesEvent event)
queueEvent(FacesEvent), then extract the node from it and set it as current node and delegate the call
to the wrapped faces event.broadcast in class UIComponentBaseprotected void processTreeNode(FacesContext context, 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(),
TreeInsertChildrenprotected boolean visitTreeNode(VisitContext context, 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.true if the visit is complete.TreeModel.isLeaf(),
TreeModel.getLevel(),
TreeInsertChildrenprotected void setCurrentModelNode(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 Object getValue()
public void setValue(Object value)
value - The tree model.public String getVar()
public void setVar(String var)
var - The name of the request attribute which exposes the wrapped data of the current node of the tree
model.public String getVarNode()
public void setVarNode(String varNode)
varNode - The name of the request attribute which exposes the current node of the tree model.Copyright © 2012–2021 OmniFaces. All rights reserved.