org.apache.myfaces.custom.tree2

Class UITreeData

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

Author: Sean Schofield Hans Bergsten (Some code taken from an example in his O'Reilly JavaServer Faces book. Copied with permission)

Field Summary
static StringCOMPONENT_FAMILY
static StringCOMPONENT_TYPE
Constructor Summary
UITreeData()
Constructor
Method Summary
voidbroadcast(FacesEvent event)
voidcollapsePath(String[] nodePath)
Expands all of the nodes in the specfied path.
voidencodeBegin(FacesContext context)
voidexpandAll()
Epands all nodes by default.
voidexpandPath(String[] nodePath)
Expands all of the nodes in the specfied path.
StringgetClientId(FacesContext context)
TreeModelgetDataModel()
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.
StringgetFamily()
TreeNodegetNode()
Calls through to the TreeModel and returns the current TreeNode or null.
StringgetNodeId()
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.
ObjectgetValue()
Gets the value of the TreeData.
StringgetVar()
Return the request-scope attribute under which the data object for the current node will be exposed when iterating.
booleanisLastChild(String nodeId)
Indicates whether or not the specified TreeNode is the last child in the List of children.
booleanisNodeExpanded()
Indicates whether or not the current TreeNode is expanded.
protected voidprocessChildNodes(FacesContext context, TreeNode parentNode, int processAction)
Process the child nodes of the supplied parent TreeNode.
voidprocessDecodes(FacesContext context)
voidprocessUpdates(FacesContext context)
voidprocessValidators(FacesContext context)
voidqueueEvent(FacesEvent event)
voidrestoreState(FacesContext context, Object state)
ObjectsaveState(FacesContext context)
voidsetNodeId(String nodeId)
voidsetValue(Object value)
Sets the value of the TreeData.
voidsetValueBinding(String name, ValueBinding binding)
voidsetVar(String var)
Set the request-scope attribute under which the data object for the current node wil be exposed when iterating.
voidtoggleExpanded()
Toggle the expanded state of the current node.

Field Detail

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY

COMPONENT_TYPE

public static final String COMPONENT_TYPE

Constructor Detail

UITreeData

public UITreeData()
Constructor

Method Detail

broadcast

public void broadcast(FacesEvent event)

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)

expandAll

public void expandAll()
Epands all nodes by default.

Parameters: expandAll boolean

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()
Indicates whether or not the current TreeNode is expanded.

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.