org.apache.click.extras.tree
Class Tree.AbstractJavascriptRenderer

java.lang.Object
  extended by org.apache.click.extras.tree.Tree.AbstractJavascriptRenderer
All Implemented Interfaces:
Tree.JavascriptRenderer
Direct Known Subclasses:
CheckboxTree.BaseCheckboxJavascriptRenderer, Tree.CookieRenderer, Tree.SessionRenderer
Enclosing class:
Tree

protected abstract class Tree.AbstractJavascriptRenderer
extends Object
implements Tree.JavascriptRenderer

Please note this class is not meant for public use.

Provides a abstract implementation of JavascriptRenderer that subclasses can extend from.


Field Summary
protected  String expandId
          holds the id of the expand html element.
protected  String iconId
          holds the id of the icon html element.
protected  String nodeExpansionString
          holds the javascript call to expand or collapse the node.
 
Constructor Summary
protected Tree.AbstractJavascriptRenderer()
           
 
Method Summary
protected  String buildString(String prefix, String infix, String postfix)
          Builds a new string consisting of a prefix, infix and postfix.
 void init(TreeNode treeNode)
          Called to initialize the renderer.
 void renderExpandAndCollapseAction(HtmlStringBuffer buffer)
          Called when the expand and collapse action is rendered.
 void renderIcon(HtmlStringBuffer buffer)
          Called when the tree icon is rendered.
 void renderTreeNodeStart(HtmlStringBuffer buffer)
          Called before a tree node is rendered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expandId

protected String expandId
holds the id of the expand html element.


iconId

protected String iconId
holds the id of the icon html element.


nodeExpansionString

protected String nodeExpansionString
holds the javascript call to expand or collapse the node.

Constructor Detail

Tree.AbstractJavascriptRenderer

protected Tree.AbstractJavascriptRenderer()
Method Detail

init

public void init(TreeNode treeNode)
Description copied from interface: Tree.JavascriptRenderer
Called to initialize the renderer.

Specified by:
init in interface Tree.JavascriptRenderer
Parameters:
treeNode - the current node rendered
See Also:
init(TreeNode), init(TreeNode)

renderTreeNodeStart

public void renderTreeNodeStart(HtmlStringBuffer buffer)
Description copied from interface: Tree.JavascriptRenderer
Called before a tree node is rendered. Enables the renderer to add attributes needed by javascript functionality for example something like:
      buffer.appendAttribute("id",expandId);
 
The code above adds a id attribute to the element, to enable the javascript code to lookup the html element by its id.

The above attribute is appended to whichever element the tree is currently rendering at the time renderTreeNodeStart is called.

Specified by:
renderTreeNodeStart in interface Tree.JavascriptRenderer
Parameters:
buffer - string buffer containing the markup
See Also:
renderTreeNodeStart(HtmlStringBuffer)

renderExpandAndCollapseAction

public void renderExpandAndCollapseAction(HtmlStringBuffer buffer)
Description copied from interface: Tree.JavascriptRenderer
Called when the expand and collapse action is rendered. Enables the renderer to add attributes needed by javascript functionality for example something like:
      buffer.append("onclick=\"handleNodeExpansion(this,event)\"");
 
The code above adds a javascript function call to the element.

The code above is appended to whichever element the tree is currently rendering at the time renderTreeNodeStart is called.

Specified by:
renderExpandAndCollapseAction in interface Tree.JavascriptRenderer
Parameters:
buffer - string buffer containing the markup
See Also:
renderExpandAndCollapseAction(HtmlStringBuffer)

renderIcon

public void renderIcon(HtmlStringBuffer buffer)
Description copied from interface: Tree.JavascriptRenderer
Called when the tree icon is rendered. Enables the renderer to add attributes needed by javascript functionality for example something like:
      buffer.appendAttribute("id",iconId);
 
The code above adds a id attribute to the element, to enable the javascript code to lookup the html element by its id.

The above attribute is appended to whichever element the tree is currently rendering at the time renderTreeNodeStart is called.

Specified by:
renderIcon in interface Tree.JavascriptRenderer
Parameters:
buffer - string buffer containing the markup
See Also:
renderIcon(HtmlStringBuffer)

buildString

protected String buildString(String prefix,
                             String infix,
                             String postfix)
Builds a new string consisting of a prefix, infix and postfix.

Parameters:
prefix - the string to append at the start of new string
infix - the string to append in the middle of the new string
postfix - the string to append at the end of the new string
Returns:
the newly create string