com.sun.webui.jsf.component
Class TreeNode2

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by com.sun.webui.jsf.component.WebuiComponent
              extended by com.sun.webui.jsf.component.TreeNode2
All Implemented Interfaces:
javax.faces.component.NamingContainer, javax.faces.component.StateHolder
Direct Known Subclasses:
Tree2

public class TreeNode2
extends WebuiComponent
implements javax.faces.component.NamingContainer

An Ajax based tree node component. This component could either be a leaf node or a non leaf node in which case it can have one or more children. Nodes can be selected by setting the selected property to true, which may be bound to a model value. Action listeners may be registered individually each node to indicate node selection. Action listeners may also be regsitered to indicate a node toggle. This would be one way of loading child nodes when the user clicks on a node's toggle icon. Note that for this to work, the Tree2 components of which this node is a child should have the "loadOnExpand" property set to "true".


Field Summary
static java.lang.String NODE_IMAGE_FACET_NAME
           
static java.lang.String NODE_LABEL_FACET_NAME
           
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
TreeNode2()
          Create a new instance of the TreeNode2.
 
Method Summary
 void broadcast(javax.faces.event.FacesEvent event)
          If a TreeNode2 component's toggleNode was clicked or the node was selected and the application had chosen to handle these events then these events need to be broadcast.
static TreeNode2 findChildNode(javax.faces.context.FacesContext context, TreeNode2 node, java.lang.String clientId)
          Given the client ID of the node and the root of the sub tree where it exists this method returns the TreeNode2 object representing the node.
static TreeNode2 findChildNode(TreeNode2 node, java.lang.String nodeId)
          Given the ID of the node and the root of the sub tree where it exists this method returns the TreeNode2 object representing the node.
 java.lang.String getFamily()
          Return the family for this component.
 java.lang.String getImageURL()
          Absolute or relative URL to the image to be rendered for the tree node.
 java.lang.String getLabel()
          Get the label for this node.
 javax.el.MethodExpression getNodeSelectedActionListenerExpression()
          The nodeSelectedActionListenerExpression attribute is used to specify a method to handle the tree node selection event which is triggered when a node is selected by the user.
 TreeNode2[] getPath()
           
 java.lang.Object getPathComponent(int index)
          Returns the path component at the specified index.
 int getPathCount()
          Returns the number of elements in the path.
 java.lang.String getRendererType()
          Return the renderer type associated with this component.
 java.lang.String getStyle()
          CSS style or styles to be applied to the outermost HTML element when this component is rendered.
 java.lang.String getStyleClass()
          CSS style class(es) to be applied to the outermost HTML element when this component is rendered.
 java.lang.String getTarget()
          The resource at the specified URL is displayed in the frame that is specified with the target attribute.
 javax.el.MethodExpression getToggleActionListenerExpression()
          The toggleActionListenerExpression attribute is used to specify a method to handle the tree node toggle event which is triggered when toggle node is clicked by the user.
 java.lang.String getToolTip()
          Sets the value of the title attribute for the HTML element.
 java.lang.String getUrl()
          Indicates that the text that is specified with the text attribute should be rendered as a hyperlink that resolves to the specified URL.
 boolean isExpanded()
          Set the expanded attribute to true to display the tree node as expanded when the component is initially rendered.
 boolean isImmediate()
          Return a flag indicating that this event should be broadcast at the next available opportunity, ususally between lifecycle phases i.e.
 boolean isLeaf()
          Returns true if the node is a leaf.
 boolean isSelected()
          Returns true if the node is selected.
 boolean isVisible()
          Indicates whether the node should be viewable by the user in the rendered HTML page.
 void queueEvent(javax.faces.event.FacesEvent e)
          If Tree2 is marked as immediate then schedule any tree related events in the earliest possible phase of the JSF lifecycle.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
          Restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setExpanded(boolean expanded)
          Set the expanded attribute to true to display the tree node as expanded when the component is initially rendered.
 void setImageURL(java.lang.String imageURL)
          Absolute or relative URL to the image to be rendered for the tree node.
 void setImmediate(boolean immediate)
          Set the "immediate execution" flag for this UIComponent.
 void setLabel(java.lang.String label)
          Set the label for this node.
 void setNodeSelectedActionListenerExpression(javax.el.MethodExpression me)
          The nodeSelectedActionListenerExpression attribute is used to specify a method to handle the tree node selection event which is triggered when a node is selected by the user.
 void setSelected(boolean selected)
          Set to true if this node should be selected.
 void setStyle(java.lang.String style)
          CSS style(s) to be applied to the outermost HTML element when this component is rendered.
 void setStyleClass(java.lang.String styleClass)
          CSS style class(es) to be applied to the outermost HTML element when this component is rendered.
 void setTarget(java.lang.String target)
          The resource at the specified URL is displayed in the frame that is specified with the target attribute.
 void setToggleActionListenerExpression(javax.el.MethodExpression me)
          The toggleActionListenerExpression attribute is used to specify a method to handle the tree node toggle event which is triggered when toggle node is clicked by the user.
 void setToolTip(java.lang.String toolTip)
          Sets the value of the title attribute for the HTML element.
 void setUrl(java.lang.String url)
          Indicates that the text that is specified with the text attribute should be rendered as a hyperlink that resolves to the specified URL.
 void setVisible(boolean visible)
          Set the visible attribute.
 
Methods inherited from class com.sun.webui.jsf.component.WebuiComponent
processDecodes, processUpdates, processValidators, setId, setRendered
 
Methods inherited from class javax.faces.component.UIComponentBase
decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, getValueExpression, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding, setValueExpression
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE_LABEL_FACET_NAME

public static final java.lang.String NODE_LABEL_FACET_NAME
See Also:
Constant Field Values

NODE_IMAGE_FACET_NAME

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

TreeNode2

public TreeNode2()
Create a new instance of the TreeNode2.

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

Specified by:
getFamily in class javax.faces.component.UIComponent

getRendererType

public java.lang.String getRendererType()

Return the renderer type associated with this component.

Overrides:
getRendererType in class javax.faces.component.UIComponentBase

queueEvent

public void queueEvent(javax.faces.event.FacesEvent e)
If Tree2 is marked as immediate then schedule any tree related events in the earliest possible phase of the JSF lifecycle.

Overrides:
queueEvent in class javax.faces.component.UIComponentBase
Parameters:
e - The Event to be queued.

broadcast

public void broadcast(javax.faces.event.FacesEvent event)
               throws javax.faces.event.AbortProcessingException
If a TreeNode2 component's toggleNode was clicked or the node was selected and the application had chosen to handle these events then these events need to be broadcast.

Overrides:
broadcast in class javax.faces.component.UIComponentBase
Parameters:
event - The FacesEvent being broadcast.
Throws:
javax.faces.event.AbortProcessingException

isImmediate

public boolean isImmediate()
Return a flag indicating that this event should be broadcast at the next available opportunity, ususally between lifecycle phases i.e. PhaseId.ANY.


setImmediate

public void setImmediate(boolean immediate)

Set the "immediate execution" flag for this UIComponent.

Parameters:
immediate - The new immediate execution flag

getToggleActionListenerExpression

public javax.el.MethodExpression getToggleActionListenerExpression()

The toggleActionListenerExpression attribute is used to specify a method to handle the tree node toggle event which is triggered when toggle node is clicked by the user. The toggleActionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean.


setToggleActionListenerExpression

public void setToggleActionListenerExpression(javax.el.MethodExpression me)

The toggleActionListenerExpression attribute is used to specify a method to handle the tree node toggle event which is triggered when toggle node is clicked by the user. The toggleActionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean.

See Also:
getToggleActionListenerExpression()

getNodeSelectedActionListenerExpression

public javax.el.MethodExpression getNodeSelectedActionListenerExpression()

The nodeSelectedActionListenerExpression attribute is used to specify a method to handle the tree node selection event which is triggered when a node is selected by the user. The nodeSelectedActionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean.


setNodeSelectedActionListenerExpression

public void setNodeSelectedActionListenerExpression(javax.el.MethodExpression me)

The nodeSelectedActionListenerExpression attribute is used to specify a method to handle the tree node selection event which is triggered when a node is selected by the user. The nodeSelectedActionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean.

See Also:
getNodeSelectedActionListenerExpression()

getStyle

public java.lang.String getStyle()
CSS style or styles to be applied to the outermost HTML element when this component is rendered.


setStyle

public void setStyle(java.lang.String style)
CSS style(s) to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyle()

getStyleClass

public java.lang.String getStyleClass()
CSS style class(es) to be applied to the outermost HTML element when this component is rendered.


setStyleClass

public void setStyleClass(java.lang.String styleClass)
CSS style class(es) to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyleClass()

isVisible

public boolean isVisible()

Indicates whether the node should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, this setting is true, so HTML for the component is included and visible to the user. If the accordion component is not visible, it can still be processed on subsequent form submissions because the HTML is present.


setVisible

public void setVisible(boolean visible)

Set the visible attribute.

See Also:
isVisible()

isSelected

public boolean isSelected()
Returns true if the node is selected.


setSelected

public void setSelected(boolean selected)
Set to true if this node should be selected.


isExpanded

public boolean isExpanded()

Set the expanded attribute to true to display the tree node as expanded when the component is initially rendered. When a node is expanded, its child tree nodes are displayed. By default, nodes are collapsed initially.


setExpanded

public void setExpanded(boolean expanded)

Set the expanded attribute to true to display the tree node as expanded when the component is initially rendered. When a node is expanded, its child tree nodes are displayed. By default, nodes are collapsed initially.

See Also:
isExpanded()

getImageURL

public java.lang.String getImageURL()

Absolute or relative URL to the image to be rendered for the tree node. Note that you cannot use the imageURL to display a theme image in the tree. You should use an image facet that contains a webuijsf:image or webuijsf:imageHyperlink tag to use a theme image. The imageURL attribute is overridden by the image facet.

When the imageURL attribute is used with the url attribute, the image is hyperlinked.


setImageURL

public void setImageURL(java.lang.String imageURL)

Absolute or relative URL to the image to be rendered for the tree node. Note that you cannot use the imageURL to display a theme image in the tree. You should use an image facet that contains a webuijsf:image or webuijsf:imageHyperlink tag to use a theme image. The imageURL attribute is overridden by the image facet.

When the imageURL attribute is used with the url attribute, the image is hyperlinked.

See Also:
getImageURL()

getUrl

public java.lang.String getUrl()

Indicates that the text that is specified with the text attribute should be rendered as a hyperlink that resolves to the specified URL. If the imageURL attribute is used with the url attribute, the image is hyperlinked. The url attribute does not apply to facets.


setUrl

public void setUrl(java.lang.String url)

Indicates that the text that is specified with the text attribute should be rendered as a hyperlink that resolves to the specified URL. If the imageURL attribute is used with the url attribute, the image is hyperlinked. The url attribute does not apply to facets.

See Also:
getUrl()

getTarget

public java.lang.String getTarget()

The resource at the specified URL is displayed in the frame that is specified with the target attribute. Values such as "_blank" that are valid for the target attribute of the <a> HTML element are also valid for this attribute in the tree components. The target attribute is useful only with the url attribute, and does not apply when a facet is used.


setTarget

public void setTarget(java.lang.String target)

The resource at the specified URL is displayed in the frame that is specified with the target attribute. Values such as "_blank" that are valid for the target attribute of the <a> HTML element are also valid for this attribute in the tree components. The target attribute is useful only with the url attribute, and does not apply when a facet is used.

See Also:
getTarget()

getLabel

public java.lang.String getLabel()

Get the label for this node. If the url or action attributes are also specified, the text is rendered as a hyperlink. If neither the url or action attributes are specified, the specified text is rendered as static text. Users can click on the text to select the node. The nodeLabel attribute does not apply when the nodeLabel facet is used.


setLabel

public void setLabel(java.lang.String label)

Set the label for this node. If the url or action attributes are also specified, the text is rendered as a hyperlink. If neither the url or action attributes are specified, the specified text is rendered as static text. Users can click on the text to select the node. The nodeLabel attribute does not apply when the nodeLabel facet is used.

See Also:
#getNodeLabel()

getToolTip

public java.lang.String getToolTip()

Sets the value of the title attribute for the HTML element. The specified text will display as a tooltip if the mouse cursor hovers over the HTML element.


setToolTip

public void setToolTip(java.lang.String toolTip)

Sets the value of the title attribute for the HTML element. The specified text will display as a tooltip if the mouse cursor hovers over the HTML element.

See Also:
getToolTip()

findChildNode

public static TreeNode2 findChildNode(TreeNode2 node,
                                      java.lang.String nodeId)
Given the ID of the node and the root of the sub tree where it exists this method returns the TreeNode2 object representing the node.

Parameters:
context - The FacesContext
node - The node representing the root of the subtree where the child node should be searched for.
nodeID - The ID of the child node.
Returns:
The TreeNode2 object representing the node.

findChildNode

public static TreeNode2 findChildNode(javax.faces.context.FacesContext context,
                                      TreeNode2 node,
                                      java.lang.String clientId)
Given the client ID of the node and the root of the sub tree where it exists this method returns the TreeNode2 object representing the node.

Parameters:
context - The FacesContext
node - The node representing the root of the subtree where the child node should be searched for.
clientId - The clientID of the child node.
Returns:
The TreeNode2 object representing the node.

isLeaf

public boolean isLeaf()
Returns true if the node is a leaf.


getPath

public TreeNode2[] getPath()

getPathCount

public int getPathCount()
Returns the number of elements in the path.

Returns:
an int giving a count of items the path

getPathComponent

public java.lang.Object getPathComponent(int index)
Returns the path component at the specified index.

Parameters:
index - an int specifying an index in the path, where 0 is the first element in the path
Returns:
the Object at that index location
Throws:
java.lang.IllegalArgumentException - if the index is beyond the length of the path

restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)
Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)
Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.