org.apache.myfaces.custom.tree2

Class UITreeData

Implemented Interfaces:
NamingContainer
Known Direct Subclasses:
HtmlTree

public class UITreeData
extends UIComponentBase
implements 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. javax.faces.render.Renderers of this component should use the appropriate facet to assist in rendering.
Version:
$Revision: 234267 $ $Date: 2005-08-21 18:55:19 +0200 (Sun, 21 Aug 2005) $
Authors:
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

Constructor Summary

UITreeData()
Constructor

Method Summary

void
broadcast(FacesEvent event)
void
collapsePath(String[] nodePath)
Expands all of the nodes in the specfied path.
void
encodeBegin(FacesContext context)
void
expandAll()
Epands all nodes by default.
void
expandPath(String[] nodePath)
Expands all of the nodes in the specfied path.
String
getClientId(FacesContext context)
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.
String
getFamily()
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()
Gets the value of the TreeData.
String
getVar()
Return the request-scope attribute under which the data object for the current node will be exposed when iterating.
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.
protected void
processChildNodes(FacesContext context, TreeNode parentNode, int processAction)
Process the child nodes of the supplied parent TreeNode.
void
processDecodes(FacesContext context)
void
processUpdates(FacesContext context)
void
processValidators(FacesContext context)
void
queueEvent(FacesEvent event)
void
restoreState(FacesContext context, Object state)
Object
saveState(FacesContext context)
void
setNodeId(String nodeId)
void
setValue(Object value)
Sets the value of the TreeData.
void
setValueBinding(String name, 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.

Field Details

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY

COMPONENT_TYPE

public static final String COMPONENT_TYPE

Constructor Details

UITreeData

public UITreeData()
Constructor

Method Details

broadcast

public void broadcast(FacesEvent event)
            throws AbortProcessingException

collapsePath

public void collapsePath(String[] nodePath)
Expands all of the nodes in the specfied path.
Parameters:
nodePath - The path to expand.

encodeBegin

public void encodeBegin(FacesContext context)
            throws IOException

expandAll

public void expandAll()
Epands all nodes by default.
Parameters:

expandPath

public void expandPath(String[] nodePath)
Expands all of the nodes in the specfied path.
Parameters:
nodePath - The path to expand.

getClientId

public String getClientId(FacesContext context)

getDataModel

public 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.
Returns:
TreeModel

getFamily

public String getFamily()

getNode

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

getNodeId

public String getNodeId()

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.
Parameters:
nodeId - The id of the node for whom the path information is needed.
Returns:
String[]

getValue

public Object getValue()
Gets the value of the TreeData.
Returns:
The value

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.
Returns:
The iterrator attribute

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.
Parameters:
nodeId - The ID of the node to check
Returns:
boolean

isNodeExpanded

public boolean isNodeExpanded()
Returns:
boolean

processChildNodes

protected void processChildNodes(FacesContext context,
                                 TreeNode parentNode,
                                 int processAction)
Process the child nodes of the supplied parent 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

processDecodes

public void processDecodes(FacesContext context)

processUpdates

public void processUpdates(FacesContext context)

processValidators

public void processValidators(FacesContext context)

queueEvent

public void queueEvent(FacesEvent event)

restoreState

public void restoreState(FacesContext context,
                         Object state)

saveState

public Object saveState(FacesContext context)

setNodeId

public void setNodeId(String nodeId)

setValue

public void setValue(Object value)
Sets the value of the TreeData.
Parameters:
value - The new value

setValueBinding

public void setValueBinding(String name,
                            ValueBinding binding)

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.
Parameters:
var - The new request-scope attribute name

toggleExpanded

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