org.apache.myfaces.custom.tree2
Class UITreeData

java.lang.Object
  |
  +--javax.faces.component.UIComponent
        |
        +--javax.faces.component.UIComponentBase
              |
              +--org.apache.myfaces.custom.tree2.UITreeData
All Implemented Interfaces:
javax.faces.component.NamingContainer, javax.faces.component.StateHolder
Direct Known Subclasses:
HtmlTree

public class UITreeData
extends javax.faces.component.UIComponentBase
implements javax.faces.component.NamingContainer

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: 1.5 $ $Date: 2005/02/26 00:26:00 $
Author:
Sean Schofield, Hans Bergsten (Some code taken from an example in his O'Reilly JavaServer Faces book. Copied with permission)

Field Summary
static java.lang.String COMPONENT_FAMILY
           
static java.lang.String COMPONENT_TYPE
           
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
UITreeData()
          Constructor
 
Method Summary
 void broadcast(javax.faces.event.FacesEvent event)
           
 void encodeBegin(javax.faces.context.FacesContext context)
           
 java.lang.String getClientId(javax.faces.context.FacesContext context)
           
 java.lang.String getFamily()
           
 TreeNode getNode()
          Calls through to the TreeModel and returns the current TreeNode or null.
 java.lang.String getNodeId()
           
 java.lang.String[] getPathInformation(java.lang.String nodeId)
          Gets an array of String containing the ID's of all of the TreeNodes in the path to the specified node.
 java.lang.Object getValue()
          Gets the value of the TreeData.
 java.lang.String getVar()
          Return the request-scope attribute under which the data object for the current node will be exposed when iterating.
 boolean isLastChild(java.lang.String nodeId)
          Indicates whether or not the specified TreeNode is the last child in the List of children.
protected  void processChildNodes(javax.faces.context.FacesContext context, TreeNode parentNode, int processAction)
          Process the child nodes of the supplied parent @{link TreeNode}.
 void processDecodes(javax.faces.context.FacesContext context)
           
 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, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setNodeId(java.lang.String nodeId)
           
 void setValue(TreeNode value)
          Sets the value of the TreeData.
 void setValueBinding(java.lang.String name, javax.faces.el.ValueBinding binding)
           
 void setVar(java.lang.String var)
          Set the request-scope attribute under which the data object for the current node wil be exposed when iterating.
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient
 
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 java.lang.String COMPONENT_TYPE
See Also:
Constant Field Values

COMPONENT_FAMILY

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

UITreeData

public UITreeData()
Constructor

Method Detail

getFamily

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

saveState

public java.lang.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,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

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
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

getClientId

public java.lang.String getClientId(javax.faces.context.FacesContext context)
Overrides:
getClientId in class javax.faces.component.UIComponentBase

setValueBinding

public void setValueBinding(java.lang.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 java.io.IOException
Overrides:
encodeBegin in class javax.faces.component.UIComponentBase
java.io.IOException

setValue

public void setValue(TreeNode value)
Sets the value of the TreeData.

Parameters:
value - The new value

getValue

public java.lang.Object getValue()
Gets the value of the TreeData.

Returns:
The value

setVar

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

Parameters:
var - The new request-scope attribute name

getVar

public java.lang.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.

Returns:
The iterrator attribute

getNode

public TreeNode getNode()
Calls through to the TreeModel and returns the current TreeNode or null.

Returns:
The current node

getNodeId

public java.lang.String getNodeId()

setNodeId

public void setNodeId(java.lang.String nodeId)

getPathInformation

public java.lang.String[] getPathInformation(java.lang.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.

Parameters:
nodeId - The id of the node for whom the path information is needed.
Returns:
String[]

isLastChild

public boolean isLastChild(java.lang.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.

Parameters:
nodeId - The ID of the node to check
Returns:
boolean

processChildNodes

protected void processChildNodes(javax.faces.context.FacesContext context,
                                 TreeNode parentNode,
                                 int processAction)
Process the child nodes of the supplied parent @{link TreeNode}. This method is protected so that it can be overriden by a subclass that may want to control how child nodes are processed.

Parameters:
context - FacesContext
parentNode - The parent node whose children are to be processed
processAction - An int representing the type of action to process