org.apache.beehive.netui.tags.tree
Class Tree

Object
  extended by SimpleTagSupport
      extended by AbstractSimpleTag
          extended by Tree
All Implemented Interfaces:
JspTag, SimpleTag, HtmlConstants, IErrorCollector, INetuiTag

public class Tree
extends AbstractSimpleTag
implements HtmlConstants, IErrorCollector

Netui tag that renders a tree control represented by a set of TreeElement objects.

Example
The following example shows a <netui:tree> tag with a set of children <netui:node> tags that form the tree's navigational structure. The tree attribute stores the tree in the Session object, under the property "tree". The imageRoot attribute points to fa older of images relative to the Page Flow directory.
  <netui:tree
    tree="{session.tree}"
    imageRoot="treeImages"
    style="tree-control"
    action="treeState">
      <netui:node label="Root Folder" expanded="true" action="treeState" target="contentFrame">
          <netui:node label="I" expanded="false" action="treeState" target="contentFrame">
              <netui:node label="A" expanded="false" action="treeState" target="contentFrame">
                  <netui:node label="1" action="treeState" target="contentFrame"/>
                  <netui:node label="2" action="treeState" target="contentFrame"/>
              </netui:node>
          </netui:node>
      </netui:node>
  </netui:tree>

Field Summary
 
Fields inherited from interface HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Constructor Summary
Tree()
           
 
Method Summary
 void collectChildError(String error)
          This method will report all collected errors.
 void doTag()
          Prepare the Tree for rendering.
 TreeElement getRootNode()
           
 String getSelectionAction()
          Return the action for selection events on the tree.
 String getTagName()
          Return the name of the Tag.
protected  TreeElement getTreeRoot(ExpressionHandling expr)
          Return the TreeControl instance for the tree control that we are rendering.
protected  void render(StringBuilder sb, HttpServletRequest request, HttpServletResponse response, TreeElement node, int level, AttributeRenderer attrs, InheritableState state)
          This is a recursive method which generates the markup for the tree.
protected  String renderTagId(String tagId, AbstractHtmlState state)
          This method will handle creating the tagId attribute.
protected  String replace(String template, String placeholder, String value)
          Replace any occurrence of the specified placeholder in the specified template string with the specified replacement value.
 void setDataSource(String dataSource)
          Sets an expression which indentifies the TreeElement that represents the root of the tree.
 void setDefaultIcon(String defaultIcon)
          Sets the default icon for TreeElements for a blank area of the tree.
 void setDisableClass(String disableClass)
          Set the style class of a tree element when is is disabled.
 void setDisabledStyle(String disabledStyle)
          Set the style of a tree element when is is disabled.
 void setExpansionAction(String action)
          Sets the action used for expanding and contracting tree nodes.
 void setExpansionTarget(String target)
          Sets the action used for expanding and contracting tree nodes.
 void setImageHandleDownLast(String imageHandleDownLast)
          Sets the image name for an open non-leaf node with no line below it.
 void setImageHandleDownMiddle(String imageHandleDownMiddle)
          Sets the image name for an open non-leaf node with a line below it.
 void setImageHandleRightLast(String imageHandleRightLast)
          Sets the image name for a closed non-leaf node with no line below it.
 void setImageHandleRightMiddle(String imageHandleRightMiddle)
          Sets the image name for a closed non-leaf node with a line below it.
 void setImageLineLast(String imageLineLast)
          Sets the image name for a blank area of the tree.
 void setImageLineMiddle(String imageLineMiddle)
          Sets the image name for an area with a line through it.
 void setImageLineVertical(String imageLineVertical)
          Sets the image name for an area with a line through it.
 void setImageRoot(String imageRoot)
          Sets the name of the directory containing the images for our icons, relative to the page including this tag.
 void setRootNode(TreeElement rootNode)
          Sets the root TreeElement of this tree.
 void setRunAtClient(boolean runAtClient)
           
 void setSelectionAction(String action)
          Sets the action used for expanding and contracting tree nodes.
 void setSelectionClass(String selectionClass)
          Set the style class of a tree element when is is selected.
 void setSelectionStyle(String selectionStyle)
          Set the style of a tree element when is is selected.
 void setTagId(String tagId)
          Set the ID of the tag.
 void setTreeClass(String treeClass)
          Sets the class attribute of the tree.
 void setTreeStyle(String treeStyle)
          Sets the style attribute of the tree.
 void setUnselectClass(String unselectClass)
          Set the style class of a tree element when is is selected.
 void setUnselectStyle(String unselectStyle)
          Set the style class of a tree element when is is not selected.
 
Methods inherited from class AbstractSimpleTag
addTagIdMapping, getBufferBody, getInlineError, getPageContext, getScriptReporter, getUserLocale, hasErrors, registerTagError, registerTagError, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tree

public Tree()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractSimpleTag
Returns:
the name of the tag.

setExpansionAction

public void setExpansionAction(String action)
                        throws JspException
Sets the action used for expanding and contracting tree nodes.

Parameters:
action - - the action
Throws:
JspException

setSelectionAction

public void setSelectionAction(String action)
                        throws JspException
Sets the action used for expanding and contracting tree nodes.

Parameters:
action - - the action
Throws:
JspException

getSelectionAction

public String getSelectionAction()
Return the action for selection events on the tree. This action will be called when a TreeElement is selected.

Returns:
the selection action name.

setExpansionTarget

public void setExpansionTarget(String target)
Sets the action used for expanding and contracting tree nodes.

Parameters:
target - - the target for expansion

setTagId

public void setTagId(String tagId)
              throws JspException
Set the ID of the tag.

Parameters:
tagId - - the tagId.
Throws:
JspException

setImageHandleDownLast

public void setImageHandleDownLast(String imageHandleDownLast)
Sets the image name for an open non-leaf node with no line below it. (Defaults to "handledownlast.gif").

Parameters:
imageHandleDownLast - - the image name (including extension)

setImageHandleDownMiddle

public void setImageHandleDownMiddle(String imageHandleDownMiddle)
Sets the image name for an open non-leaf node with a line below it. (Defaults to "handledownmiddle.gif").

Parameters:
imageHandleDownMiddle - - the image name (including extension)

setImageHandleRightLast

public void setImageHandleRightLast(String imageHandleRightLast)
Sets the image name for a closed non-leaf node with no line below it. (Defaults to "handlerightlast.gif").

Parameters:
imageHandleRightLast - - the image name (including extension)

setImageHandleRightMiddle

public void setImageHandleRightMiddle(String imageHandleRightMiddle)
Sets the image name for a closed non-leaf node with a line below it. (Defaults to "handlerightmiddle.gif").

Parameters:
imageHandleRightMiddle - - the image name (including extension)

setImageLineLast

public void setImageLineLast(String imageLineLast)
Sets the image name for a blank area of the tree. (Defaults to "linelastnode.gif").

Parameters:
imageLineLast - - the image name (including extension)

setDefaultIcon

public void setDefaultIcon(String defaultIcon)
Sets the default icon for TreeElements for a blank area of the tree. (Defaults to "linelastnode.gif").

Parameters:
defaultIcon - - the image name of the defaultIcon

setImageLineMiddle

public void setImageLineMiddle(String imageLineMiddle)
Sets the image name for an area with a line through it. (Defaults to "linemiddlenode.gif").

Parameters:
imageLineMiddle - - the image name (including extension)

setImageLineVertical

public void setImageLineVertical(String imageLineVertical)
Sets the image name for an area with a line through it. (Defaults to "linevertical.gif").

Parameters:
imageLineVertical - - the image name (including extension)

setImageRoot

public void setImageRoot(String imageRoot)
Sets the name of the directory containing the images for our icons, relative to the page including this tag.

Parameters:
imageRoot - - the directory name

setRunAtClient

public void setRunAtClient(boolean runAtClient)
Parameters:
runAtClient -

setRootNode

public void setRootNode(TreeElement rootNode)
Sets the root TreeElement of this tree.

Parameters:
rootNode - - the root treeNode

getRootNode

public TreeElement getRootNode()

setSelectionStyle

public void setSelectionStyle(String selectionStyle)
Set the style of a tree element when is is selected. This results in a style attribute being generated for this tree node.

Parameters:
selectionStyle -

setDisableClass

public void setDisableClass(String disableClass)
Set the style class of a tree element when is is disabled. A disabled element will have a style can my be expanded/contracted, but my not be selected.

Parameters:
disableClass -

setDisabledStyle

public void setDisabledStyle(String disabledStyle)
Set the style of a tree element when is is disabled. A disabled element will have a style can my be expanded/contracted, but my not be selected.

Parameters:
disabledStyle -

setSelectionClass

public void setSelectionClass(String selectionClass)
Set the style class of a tree element when is is selected. This results in a class attribute being generated for this tree node.

Parameters:
selectionClass -

setUnselectStyle

public void setUnselectStyle(String unselectStyle)
Set the style class of a tree element when is is not selected. This results in a style attribute being generated for this tree node.

Parameters:
unselectStyle -

setUnselectClass

public void setUnselectClass(String unselectClass)
Set the style class of a tree element when is is selected. This results in a class attribute being generated for this tree node.

Parameters:
unselectClass -

setTreeStyle

public void setTreeStyle(String treeStyle)
Sets the style attribute of the tree.

Parameters:
treeStyle - - the style

setTreeClass

public void setTreeClass(String treeClass)
Sets the class attribute of the tree.

Parameters:
treeClass - - the style

setDataSource

public void setDataSource(String dataSource)
Sets an expression which indentifies the TreeElement that represents the root of the tree.

Parameters:
dataSource - - the tree attribute name

doTag

public void doTag()
           throws JspException,
                  IOException
Prepare the Tree for rendering.

Specified by:
doTag in interface SimpleTag
Overrides:
doTag in class SimpleTagSupport
Throws:
JspException - if a JSP exception has occurred
IOException

getTreeRoot

protected TreeElement getTreeRoot(ExpressionHandling expr)
                           throws JspException
Return the TreeControl instance for the tree control that we are rendering.

Throws:
JspException - if no TreeControl instance can be found

render

protected void render(StringBuilder sb,
                      HttpServletRequest request,
                      HttpServletResponse response,
                      TreeElement node,
                      int level,
                      AttributeRenderer attrs,
                      InheritableState state)
               throws JspException
This is a recursive method which generates the markup for the tree.

Parameters:
sb -
request -
response -
node -
level -
attrs -
state -
Throws:
JspException

replace

protected String replace(String template,
                         String placeholder,
                         String value)
Replace any occurrence of the specified placeholder in the specified template string with the specified replacement value.

Parameters:
template - Pattern string possibly containing the placeholder
placeholder - Placeholder expression to be replaced
value - Replacement value for the placeholder

renderTagId

protected final String renderTagId(String tagId,
                                   AbstractHtmlState state)
This method will handle creating the tagId attribute. The tagId attribute indentifies the tag in the generated HTML. There is a lookup table created in JavaScript mapping the tagId to the actual name. The tagId is also run through the naming service so it can be scoped. Some tags will write that tagid out as the id attribute of the HTML tag being generated.

Parameters:
tagId -
state -
Returns:
String

collectChildError

public void collectChildError(String error)
This method will report all collected errors.

Specified by:
collectChildError in interface IErrorCollector
Parameters:
error -