public class Tree extends TreeFamily implements 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 String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILY
BEANINFO_KEY, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
SEPARATOR_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.
|
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.
|
void |
queueEvent(FacesEvent event)
An override which wraps the given faces event in a specific faces event which remembers the current model node.
|
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.
|
boolean |
visitTree(VisitContext context,
VisitCallback callback)
Set the root node as current node and delegate the call to
visitTreeNode(VisitContext, VisitCallback) . |
encodeChildren, getFamily, getRendersChildren, processDecodes, processUpdates, processValidators
addClientBehavior, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
encodeAll, getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getValueExpression, initialStateMarked, isCompositeComponent, isInView, popComponentFromEL, processEvent, pushComponentToEL, setInView, subscribeToEvent, unsubscribeFromEvent
public static final String COMPONENT_TYPE
public String getContainerClientId(FacesContext context)
getContainerClientId
in class UIComponent
TreeModel.getIndex()
public void setValueExpression(String name, ValueExpression binding)
var
or varNode
attribute.
Finally it delegates to the super method.setValueExpression
in class UIComponent
IllegalArgumentException
- When this value expression is been set on var
or
varNode
attribute.public void queueEvent(FacesEvent event)
queueEvent
in class UIComponentBase
public boolean visitTree(VisitContext context, VisitCallback callback)
visitTreeNode(VisitContext, VisitCallback)
.visitTree
in class UIComponent
context
- The visit context to work with.callback
- The visit callback to work with.public void broadcast(FacesEvent event) throws AbortProcessingException
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 UIComponentBase
AbortProcessingException
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.