com.sun.webui.jsf.component
Class TreeNode

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by com.sun.webui.jsf.component.TreeNode
All Implemented Interfaces:
java.io.Serializable, javax.faces.component.NamingContainer, javax.faces.component.StateHolder
Direct Known Subclasses:
Tree

public class TreeNode
extends javax.faces.component.UIComponentBase
implements javax.faces.component.NamingContainer, java.io.Serializable

The TreeNode component is used to insert a node in a tree structure.

See Also:
Serialized Form

Field Summary
static java.lang.String CONTENT_FACET_KEY
           This is the facet key used to define the content for the TreeNode.
static java.lang.String IMAGE_FACET_KEY
           This is the facet key used to set a custom image for this TreeNode.
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
TreeNode()
          Constructor.
 
Method Summary
 void addActionListener(javax.faces.event.ActionListener listener)
          Add an action listener instance for the IconHyperlink representing this node's turner.
 void broadcast(javax.faces.event.FacesEvent event)
           
static Tree getAbsoluteRoot(javax.faces.component.UIComponent node)
           This method returns the root Tree object reference.
 javax.el.MethodExpression getActionExpression()
          The actionExpression attribute is used to specify the action to take when this component is activated by the user.
 javax.el.MethodExpression getActionListenerExpression()
          The actionListenerExpression attribute is used to specify a method to handle an action event that is triggered when a component is activated by the user.
 javax.faces.event.ActionListener[] getActionListeners()
          Get all ActionListener instances for this node's turner IconHyperlink click.
 TreeNode getChildNode(java.lang.String id)
          Given the ID of a child of this node this method returns the TreeNode component corresponding to this ID.
static TreeNode[] getChildTreeNodes(javax.faces.component.UIComponent node)
           This method returns an array of child treeNodes only.
 Hyperlink getContentHyperlink()
           
 java.lang.String getFamily()
          Return the family for this component.
 java.lang.String getHandleIcon(java.lang.String value)
           This method enables the icon to switch from expanded to collapsed, or from collapsed to expanded depending on the current state of this component.
 java.util.List getImageKeys()
           This method determines the theme images that should be drawn from left to right (0 to x) when rendering the lines before the text for this node.
 java.lang.String getImageURL()
          Absolute or relative URL to the image to be rendered for the tree node.
 ImageHyperlink getNodeImageHyperlink()
           
static TreeNode getParentTreeNode(javax.faces.component.UIComponent node)
           This method returns the closest parent that is a TreeNode, or null if not found.
 boolean getRendersChildren()
          This component renders its children
 java.lang.String getStyle()
          CSS style(s) 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.
 java.lang.String getText()
          Specifies the text for this component.
 java.lang.String getToolTip()
          Sets the value of the title attribute for the HTML element.
 IconHyperlink getTurnerImageHyperlink()
           
 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 isVisible()
          Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page.
 void removeActionListener(javax.faces.event.ActionListener listener)
          Remove an action listener instance from the list for this node's turner IconHyperlink.
 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 setActionExpression(javax.el.MethodExpression actionExpression)
          The actionExpression attribute is used to specify the action to take when this component is activated by the user.
 void setActionListenerExpression(javax.el.MethodExpression me)
          The actionListenerExpression attribute is used to specify a method to handle an action event that is triggered when a component is activated by the user.
 void setExpanded(boolean expanded)
          Set the expanded attribute to true to display the tree node as expanded when the component is initially rendered.
 void setId(java.lang.String id)
          The component identifier for this component.
 void setImageURL(java.lang.String imageURL)
          Absolute or relative URL to the image to be rendered for the tree node.
 void setRendered(boolean rendered)
          Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page.
 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 setText(java.lang.String text)
          Specifies the text for this component.
 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)
          Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page.
 
Methods inherited from class javax.faces.component.UIComponentBase
decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendererType, getValueBinding, getValueExpression, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, 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

IMAGE_FACET_KEY

public static final java.lang.String IMAGE_FACET_KEY

This is the facet key used to set a custom image for this TreeNode. (image)

See Also:
Constant Field Values

CONTENT_FACET_KEY

public static final java.lang.String CONTENT_FACET_KEY

This is the facet key used to define the content for the TreeNode. (content)

See Also:
Constant Field Values
Constructor Detail

TreeNode

public TreeNode()
Constructor.

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

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

setId

public void setId(java.lang.String id)
The component identifier for this component. This value must be unique within the closest parent component that is a naming container.

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

setRendered

public void setRendered(boolean rendered)
Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page. If set to false, the rendered HTML page does not include the HTML for the component. If the component is not rendered, it is also not processed on any subsequent form submission.

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

getActionExpression

public javax.el.MethodExpression getActionExpression()

The actionExpression attribute is used to specify the action to take when this component is activated by the user. The value of the action attribute must be one of the following:

In the Tree and TreeNode components, the action applies only when attributes are used to define the tree and tree nodes. When facets are used, the action attribute does not apply to the facets.


setActionExpression

public void setActionExpression(javax.el.MethodExpression actionExpression)

The actionExpression attribute is used to specify the action to take when this component is activated by the user. The value of the action attribute must be one of the following:

In the Tree and TreeNode components, the action applies only when attributes are used to define the tree and tree nodes. When facets are used, the action attribute does not apply to the facets.

See Also:
getActionExpression()

getActionListenerExpression

public javax.el.MethodExpression getActionListenerExpression()

The actionListenerExpression attribute is used to specify a method to handle an action event that is triggered when a component is activated by the user. The actionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean. The method must take a single parameter that is an ActionEvent, and its return type must be void. The class that defines the method must implement the java.io.Serializable interface or javax.faces.component.StateHolder interface.

In the TreeNode component, the method specified by the actionListenerExpression atttribute is invoked when the node's handle icon is clicked.


setActionListenerExpression

public void setActionListenerExpression(javax.el.MethodExpression me)

The actionListenerExpression attribute is used to specify a method to handle an action event that is triggered when a component is activated by the user. The actionListenerExpression attribute value must be a Unified EL expression that resolves to a method in a backing bean. The method must take a single parameter that is an ActionEvent, and its return type must be void. The class that defines the method must implement the java.io.Serializable interface or javax.faces.component.StateHolder interface.

In the TreeNode component, the method specified by the actionListenerExpression atttribute is invoked when the node's handle icon is clicked.

See Also:
getActionListenerExpression()

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

getStyle

public java.lang.String getStyle()

CSS style(s) 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()

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

getText

public java.lang.String getText()

Specifies the text for this component. 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. The text attribute does not apply when the content facet is used.


setText

public void setText(java.lang.String text)

Specifies the text for this component. 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. The text attribute does not apply when the content facet is used.

See Also:
getText()

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

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

isVisible

public boolean isVisible()

Use the visible attribute to indicate whether the component 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, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.


setVisible

public void setVisible(boolean visible)

Use the visible attribute to indicate whether the component 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, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.

See Also:
isVisible()

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

getRendersChildren

public boolean getRendersChildren()
This component renders its children

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

getImageKeys

public java.util.List getImageKeys()

This method determines the theme images that should be drawn from left to right (0 to x) when rendering the lines before the text for this node.

Returns:
A List of Strings that represent theme keys for the images to be drawn. The first list element is the first image to display when rendering left to right.

getChildNode

public TreeNode getChildNode(java.lang.String id)
Given the ID of a child of this node this method returns the TreeNode component corresponding to this ID.

Parameters:
id - The id of the child node being searched for.
Returns:
the TreeNode object if found, null otherwise.

getParentTreeNode

public static TreeNode getParentTreeNode(javax.faces.component.UIComponent node)

This method returns the closest parent that is a TreeNode, or null if not found.

Parameters:
node - The starting TreeNode.
Returns:
The clost parent TreeNode

getAbsoluteRoot

public static Tree getAbsoluteRoot(javax.faces.component.UIComponent node)

This method returns the root Tree object reference. This method is required to find out this is a client side tree and if nodes should expand on selection of the anything other than the handler images. The "clientSide" and "expandOnSelect" attributes of the Tree component are used to supply this information.

Returns:
The root Tree component.

getChildTreeNodes

public static TreeNode[] getChildTreeNodes(javax.faces.component.UIComponent node)

This method returns an array of child treeNodes only.

Parameters:
node - The starting TreeNode.
Returns:
The clost parent TreeNode

addActionListener

public void addActionListener(javax.faces.event.ActionListener listener)

Add an action listener instance for the IconHyperlink representing this node's turner.

Parameters:
listener - The ActionListener instance to register for turner IconHyperlink clicks.

getActionListeners

public javax.faces.event.ActionListener[] getActionListeners()

Get all ActionListener instances for this node's turner IconHyperlink click.

Returns:
ActionListener[] The list of listeners for this node's turner IconHyperlink click.

removeActionListener

public void removeActionListener(javax.faces.event.ActionListener listener)

Remove an action listener instance from the list for this node's turner IconHyperlink.

Parameters:
listener - The ActionListener instance to remove.

getHandleIcon

public java.lang.String getHandleIcon(java.lang.String value)

This method enables the icon to switch from expanded to collapsed, or from collapsed to expanded depending on the current state of this component.

Parameters:
value - The current value of the Icon. It will use the current value to re-use first/last information from the old key.
Returns:
The new (or same if the state hasn't changed) icon state

getContentHyperlink

public Hyperlink getContentHyperlink()

getNodeImageHyperlink

public ImageHyperlink getNodeImageHyperlink()

getTurnerImageHyperlink

public IconHyperlink getTurnerImageHyperlink()

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.