org.apache.myfaces.custom.tree2

Class HtmlTreeRenderer


public class HtmlTreeRenderer
extends Renderer

Version:
$Revision: 279360 $ $Date: 2005-09-07 17:51:08 +0200 (Wed, 07 Sep 2005) $
Authors:
Sean Schofield
Chris Barlow
Hans Bergsten (Some code taken from an example in his O'Reilly JavaServer Faces book. Copied with permission)

Field Summary

protected static String
ROOT_NODE_ID
protected static String
TOGGLE_SPAN

Method Summary

protected void
afterNodeEncode(FacesContext context, ResponseWriter out)
protected void
beforeNodeEncode(FacesContext context, ResponseWriter out, HtmlTree tree)
void
decode(FacesContext context, UIComponent component)
void
encodeBegin(FacesContext context, UIComponent component)
void
encodeChildren(FacesContext context, UIComponent component)
Renders the whole tree.
protected void
encodeCurrentNode(FacesContext context, ResponseWriter out, HtmlTree tree)
Encodes the current node.
protected void
encodeTree(FacesContext context, ResponseWriter out, HtmlTree tree, String parentId, int childCount)
Encodes the tree and its children.
protected boolean
getBoolean(UIComponent component, String attributeName, boolean defaultValue)
Helper method for getting the boolean value of an attribute.
boolean
getRendersChildren()

Field Details

ROOT_NODE_ID

protected static final String ROOT_NODE_ID

TOGGLE_SPAN

protected static final String TOGGLE_SPAN

Method Details

afterNodeEncode

protected void afterNodeEncode(FacesContext context,
                               ResponseWriter out)
            throws IOException

beforeNodeEncode

protected void beforeNodeEncode(FacesContext context,
                                ResponseWriter out,
                                HtmlTree tree)
            throws IOException

decode

public void decode(FacesContext context,
                   UIComponent component)

encodeBegin

public void encodeBegin(FacesContext context,
                        UIComponent component)
            throws IOException

encodeChildren

public void encodeChildren(FacesContext context,
                           UIComponent component)
            throws IOException
Renders the whole tree. It generates a <span> element with an id attribute if the component has been given an explicit ID. The model nodes are rendered recursively by the private encodeNodes method.
Parameters:
context - FacesContext
component - The component whose children are to be rendered

encodeCurrentNode

protected void encodeCurrentNode(FacesContext context,
                                 ResponseWriter out,
                                 HtmlTree tree)
            throws IOException
Encodes the current node. It is protected so that custom Renderers can extend it. That might be useful if you would like to render additional per node information besides the tree node.
Parameters:
context - FacesContext
out - ResponseWriter
tree - HtmlTree

encodeTree

protected void encodeTree(FacesContext context,
                          ResponseWriter out,
                          HtmlTree tree,
                          String parentId,
                          int childCount)
            throws IOException
Encodes the tree and its children.
Parameters:
context - FacesContext
out - ResponseWriter
tree - HtmlTree
parentId - The parent's node id (where parent is the parent of the node we are about to render.)
childCount - If this node is a child of another node, the count indicates which child number it is (used to construct the id of the next node to render.)

getBoolean

protected boolean getBoolean(UIComponent component,
                             String attributeName,
                             boolean defaultValue)
Helper method for getting the boolean value of an attribute. If the attribute is not specified, then return the default value.
Parameters:
component - The component for which the attributes are to be checked.
attributeName - The name of the boolean attribute.
defaultValue - The default value of the attribute (to be returned if no value found).
Returns:
boolean

getRendersChildren

public boolean getRendersChildren()