org.apache.myfaces.custom.tree2
Class UITreeData

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.apache.myfaces.custom.tree2.UITreeData
All Implemented Interfaces:
EventListener, javax.faces.component.NamingContainer, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.component.UniqueIdVendor, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, org.apache.myfaces.custom.tree2.Tree
Direct Known Subclasses:
AbstractHtmlTree

@JSFComponent
public class UITreeData
extends javax.faces.component.UIComponentBase
implements javax.faces.component.NamingContainer, org.apache.myfaces.custom.tree2.Tree, javax.faces.component.UniqueIdVendor

TreeData is a UIComponent that supports binding data stored in a tree represented by a TreeNode instance. During iterative processing over the tree nodes in the data model, the object for the current node is exposed as a request attribute under the key specified by the var property. Renderers of this component should use the appropriate facet to assist in rendering.

Version:
$Revision: 703742 $ $Date: 2008-10-11 17:10:36 -0500 (sáb, 11 oct 2008) $
Author:
Sean Schofield, Hans Bergsten (Some code taken from an example in his O'Reilly JavaServer Faces book. Copied with permission)

Field Summary
static String COMPONENT_FAMILY
           
static String COMPONENT_TYPE
           
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
UITreeData()
          Constructor
 
Method Summary
 void broadcast(javax.faces.event.FacesEvent event)
           
 void collapseAll()
          Collapse all nodes by default.
 void collapsePath(String[] nodePath)
          Expands all of the nodes in the specfied path.
 String createUniqueId(javax.faces.context.FacesContext context, String seed)
          
 void encodeBegin(javax.faces.context.FacesContext context)
           
 void encodeEnd(javax.faces.context.FacesContext context)
           
 void expandAll()
          Epands all nodes by default.
 void expandPath(String[] nodePath)
          Expands all of the nodes in the specfied path.
 String getContainerClientId(javax.faces.context.FacesContext context)
           
 org.apache.myfaces.custom.tree2.TreeModel getDataModel()
          Returns a previously cached TreeModel, if any, or sets the cache variable to either the current value (if its a TreeModel) or to a new instance of TreeModel (if it's a TreeNode) with the provided value object as the root node.
protected  javax.faces.context.FacesContext getFacesContext()
           
 String getFamily()
           
 Object getModel()
          Gets the model of the TreeData - due to backwards-compatibility, this can also be retrieved by getValue.
 org.apache.myfaces.custom.tree2.TreeNode getNode()
          Calls through to the TreeModel and returns the current TreeNode or null.
 String getNodeId()
           
 String[] getPathInformation(String nodeId)
          Gets an array of String containing the ID's of all of the TreeNodes in the path to the specified node.
 Object getValue()
          Deprecated.  
 String getVar()
          Return the request-scope attribute under which the data object for the current node will be exposed when iterating.
 boolean invokeOnComponent(javax.faces.context.FacesContext context, String clientId, javax.faces.component.ContextCallback callback)
           
 boolean isLastChild(String nodeId)
          Indicates whether or not the specified TreeNode is the last child in the List of children.
 boolean isNodeExpanded()
          Indicates whether or not the current TreeNode is expanded.
 boolean isNodeSelected()
          Indicates whether or not the current TreeNode is selected.
 void processDecodes(javax.faces.context.FacesContext context)
           
protected  void processNodes(javax.faces.context.FacesContext context, int processAction, org.apache.myfaces.custom.tree2.TreeWalker walker)
           
 void processUpdates(javax.faces.context.FacesContext context)
           
 void processValidators(javax.faces.context.FacesContext context)
           
 void queueEvent(javax.faces.event.FacesEvent event)
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setModel(Object model)
          Sets the model of the TreeData - due to backwards-compatibility, this can also be set by calling setValue.
 void setNodeId(String nodeId)
           
 void setNodeSelected(javax.faces.event.ActionEvent event)
          Implements the ActionListener interface.
 void setValue(Object value)
          Deprecated.  
 void setValueBinding(String name, javax.faces.el.ValueBinding binding)
           
 void setVar(String var)
          Set the request-scope attribute under which the data object for the current node wil be exposed when iterating.
 void toggleExpanded()
          Toggle the expanded state of the current node.
 boolean visitTree(javax.faces.component.visit.VisitContext context, javax.faces.component.visit.VisitCallback callback)
           
 
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, clearInitialState, decode, encodeAll, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, initialStateMarked, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient
 
Methods inherited from class javax.faces.component.UIComponent
getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final String COMPONENT_TYPE
See Also:
Constant Field Values

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY
See Also:
Constant Field Values
Constructor Detail

UITreeData

public UITreeData()
Constructor

Method Detail

getFamily

public String getFamily()
Specified by:
getFamily in class javax.faces.component.UIComponent

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context)
               throws IOException
Overrides:
encodeEnd in class javax.faces.component.UIComponentBase
Throws:
IOException

queueEvent

public void queueEvent(javax.faces.event.FacesEvent event)
Overrides:
queueEvent in class javax.faces.component.UIComponentBase

broadcast

public void broadcast(javax.faces.event.FacesEvent event)
               throws javax.faces.event.AbortProcessingException
Overrides:
broadcast in class javax.faces.component.UIComponentBase
Throws:
javax.faces.event.AbortProcessingException

processDecodes

public void processDecodes(javax.faces.context.FacesContext context)
Overrides:
processDecodes in class javax.faces.component.UIComponentBase

processValidators

public void processValidators(javax.faces.context.FacesContext context)
Overrides:
processValidators in class javax.faces.component.UIComponentBase

processUpdates

public void processUpdates(javax.faces.context.FacesContext context)
Overrides:
processUpdates in class javax.faces.component.UIComponentBase

getContainerClientId

public String getContainerClientId(javax.faces.context.FacesContext context)
Overrides:
getContainerClientId in class javax.faces.component.UIComponent

setValueBinding

public void setValueBinding(String name,
                            javax.faces.el.ValueBinding binding)
Overrides:
setValueBinding in class javax.faces.component.UIComponentBase

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context)
                 throws IOException
Overrides:
encodeBegin in class javax.faces.component.UIComponentBase
Throws:
IOException

setValue

public void setValue(Object value)
Deprecated. 

Sets the value of the TreeData.

Parameters:
value - The new value

getModel

public Object getModel()
Gets the model of the TreeData - due to backwards-compatibility, this can also be retrieved by getValue.

Specified by:
getModel in interface org.apache.myfaces.custom.tree2.Tree
Returns:
The value

setModel

public void setModel(Object model)
Sets the model of the TreeData - due to backwards-compatibility, this can also be set by calling setValue.

Specified by:
setModel in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
model - The new model

getValue

public Object getValue()
Deprecated. 

Gets the value of the TreeData.

Returns:
The value

setVar

public void setVar(String var)
Set the request-scope attribute under which the data object for the current node wil be exposed when iterating.

Specified by:
setVar in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
var - The new request-scope attribute name

getVar

public String getVar()
Return the request-scope attribute under which the data object for the current node will be exposed when iterating. This property is not enabled for value binding expressions.

Specified by:
getVar in interface org.apache.myfaces.custom.tree2.Tree
Returns:
The iterator attribute

getNode

public org.apache.myfaces.custom.tree2.TreeNode getNode()
Calls through to the TreeModel and returns the current TreeNode or null.

Specified by:
getNode in interface org.apache.myfaces.custom.tree2.Tree
Returns:
The current node

getNodeId

public String getNodeId()
Specified by:
getNodeId in interface org.apache.myfaces.custom.tree2.Tree

setNodeId

public void setNodeId(String nodeId)
Specified by:
setNodeId in interface org.apache.myfaces.custom.tree2.Tree

invokeOnComponent

public boolean invokeOnComponent(javax.faces.context.FacesContext context,
                                 String clientId,
                                 javax.faces.component.ContextCallback callback)
                          throws javax.faces.FacesException
Overrides:
invokeOnComponent in class javax.faces.component.UIComponentBase
Throws:
javax.faces.FacesException

visitTree

public boolean visitTree(javax.faces.component.visit.VisitContext context,
                         javax.faces.component.visit.VisitCallback callback)
Overrides:
visitTree in class javax.faces.component.UIComponentBase

getFacesContext

protected javax.faces.context.FacesContext getFacesContext()
Overrides:
getFacesContext in class javax.faces.component.UIComponentBase

getPathInformation

public String[] getPathInformation(String nodeId)
Gets an array of String containing the ID's of all of the TreeNodes in the path to the specified node. The path information will be an array of String objects representing node ID's. The array will starting with the ID of the root node and end with the ID of the specified node.

Specified by:
getPathInformation in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
nodeId - The id of the node for whom the path information is needed.
Returns:
String[]

isLastChild

public boolean isLastChild(String nodeId)
Indicates whether or not the specified TreeNode is the last child in the List of children. If the node id provided corresponds to the root node, this returns true.

Specified by:
isLastChild in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
nodeId - The ID of the node to check
Returns:
boolean

getDataModel

public org.apache.myfaces.custom.tree2.TreeModel getDataModel()
Returns a previously cached TreeModel, if any, or sets the cache variable to either the current value (if its a TreeModel) or to a new instance of TreeModel (if it's a TreeNode) with the provided value object as the root node.

Specified by:
getDataModel in interface org.apache.myfaces.custom.tree2.Tree
Returns:
TreeModel

expandAll

public void expandAll()
Epands all nodes by default.

Specified by:
expandAll in interface org.apache.myfaces.custom.tree2.Tree

collapseAll

public void collapseAll()
Collapse all nodes by default.

Specified by:
collapseAll in interface org.apache.myfaces.custom.tree2.Tree

expandPath

public void expandPath(String[] nodePath)
Expands all of the nodes in the specfied path.

Specified by:
expandPath in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
nodePath - The path to expand.

collapsePath

public void collapsePath(String[] nodePath)
Expands all of the nodes in the specfied path.

Specified by:
collapsePath in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
nodePath - The path to expand.

processNodes

protected void processNodes(javax.faces.context.FacesContext context,
                            int processAction,
                            org.apache.myfaces.custom.tree2.TreeWalker walker)

toggleExpanded

public void toggleExpanded()
Toggle the expanded state of the current node.

Specified by:
toggleExpanded in interface org.apache.myfaces.custom.tree2.Tree

isNodeExpanded

public boolean isNodeExpanded()
Indicates whether or not the current TreeNode is expanded.

Specified by:
isNodeExpanded in interface org.apache.myfaces.custom.tree2.Tree
Returns:
boolean

setNodeSelected

public void setNodeSelected(javax.faces.event.ActionEvent event)
Implements the ActionListener interface. Basically, this method is used to listen for node selection events (when a user has clicked on a leaf node.)

Specified by:
setNodeSelected in interface org.apache.myfaces.custom.tree2.Tree
Parameters:
event - ActionEvent

isNodeSelected

public boolean isNodeSelected()
Indicates whether or not the current TreeNode is selected.

Specified by:
isNodeSelected in interface org.apache.myfaces.custom.tree2.Tree
Returns:
boolean

createUniqueId

public String createUniqueId(javax.faces.context.FacesContext context,
                             String seed)

Specified by:
createUniqueId in interface javax.faces.component.UniqueIdVendor
Since:
2.0


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.