org.apache.myfaces.custom.tree2
Class HtmlTreeRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by org.apache.myfaces.custom.tree2.HtmlTreeRenderer

public class HtmlTreeRenderer
extends javax.faces.render.Renderer

Version:
$Revision: 987802 $ $Date: 2010-08-21 12:41:17 -0500 (Sat, 21 Aug 2010) $
Author:
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
           
 
Constructor Summary
HtmlTreeRenderer()
           
 
Method Summary
protected  void afterNodeEncode(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter out)
           
protected  void beforeNodeEncode(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter out, org.apache.myfaces.custom.tree2.HtmlTree tree)
           
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Renders the whole tree.
protected  void encodeCurrentNode(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter out, org.apache.myfaces.custom.tree2.HtmlTree tree)
          Encodes the current node.
protected  void encodeTree(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter out, org.apache.myfaces.custom.tree2.HtmlTree tree, TreeWalker walker)
          Encodes the tree and its children.
protected  boolean getBoolean(javax.faces.component.UIComponent component, String attributeName, boolean defaultValue)
          Helper method for getting the boolean value of an attribute.
 boolean getRendersChildren()
           
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, encodeEnd, getConvertedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOGGLE_SPAN

protected static final String TOGGLE_SPAN
See Also:
Constant Field Values

ROOT_NODE_ID

protected static final String ROOT_NODE_ID
See Also:
Constant Field Values
Constructor Detail

HtmlTreeRenderer

public HtmlTreeRenderer()
Method Detail

getRendersChildren

public boolean getRendersChildren()
Overrides:
getRendersChildren in class javax.faces.render.Renderer

decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
Overrides:
decode in class javax.faces.render.Renderer

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws IOException
Overrides:
encodeBegin in class javax.faces.render.Renderer
Throws:
IOException

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context,
                           javax.faces.component.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.

Overrides:
encodeChildren in class javax.faces.render.Renderer
Parameters:
context - FacesContext
component - The component whose children are to be rendered
Throws:
IOException

encodeTree

protected void encodeTree(javax.faces.context.FacesContext context,
                          javax.faces.context.ResponseWriter out,
                          org.apache.myfaces.custom.tree2.HtmlTree tree,
                          TreeWalker walker)
                   throws IOException
Encodes the tree and its children.

Parameters:
context - FacesContext
out - ResponseWriter
tree - HtmlTree
walker - TreeWalker
Throws:
IOException

encodeCurrentNode

protected void encodeCurrentNode(javax.faces.context.FacesContext context,
                                 javax.faces.context.ResponseWriter out,
                                 org.apache.myfaces.custom.tree2.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
Throws:
IOException

beforeNodeEncode

protected void beforeNodeEncode(javax.faces.context.FacesContext context,
                                javax.faces.context.ResponseWriter out,
                                org.apache.myfaces.custom.tree2.HtmlTree tree)
                         throws IOException
Throws:
IOException

afterNodeEncode

protected void afterNodeEncode(javax.faces.context.FacesContext context,
                               javax.faces.context.ResponseWriter out)
                        throws IOException
Throws:
IOException

getBoolean

protected boolean getBoolean(javax.faces.component.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


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.