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

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

public class Tree
extends AbstractSimpleTag
implements HtmlConstants, IAttributeConsumer, 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:treeLabel> and <netui:treeItem> tags that form the tree's navigational structure. The dataSource attribute identifies the TreeElement in the appropriate binding context; in this case, the page flow context is used. The selectionAction attribute is required so there can be a postback to the tree. tagId is used to uniquely identify a tree on the page.
  <netui:tree
    dataSource="pageflow.myTree"
    selectionAction="postback"
    tagId="myTree">
      <netui:treeItem expanded="true" >
          <netui:treeLabel>Root Folder</netui:treeLabel>
          <netui:treeItem expanded="false">
              <netui:treeLabel>I</netui:treeLabel>
              <netui:treeItem expanded="false">
                  <netui:treeLabel>A</netui:treeLabel>
                  <netui:treeItem>1</netui:treeItem>
                  <netui:treeItem>2</netui:treeItem>
              </netui:treeItem>
          </netui:treeItem>
      </netui:treeItem>
  </netui:tree>

Field Summary
 
Fields inherited from interface HtmlConstants
ABBR, ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, AREA, AXIS, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COLSPAN, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEADERS, 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, LANGUAGE, 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, ROWSPAN, RULES, SCOPE, SCRIPT, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TBODY, TD, TEXT, TEXTAREA, TFOOT, TH, THEAD, 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()
          Return the root node of the tree.
 String getSelectionAction()
          Return the action for selection action 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  String renderTagId(HttpServletRequest request, 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 setAttribute(String name, String value, String facet)
          Set an attribute value on the implementing class.
 void setDataSource(String dataSource)
          Sets an expression which indentifies the TreeElement that represents the root of the tree.
 void setDisabledStyle(String disabledStyle)
          Set the style of a tree element when is is disabled.
 void setDisabledStyleClass(String disableStyleClass)
          Set the style class of a tree element when is is disabled.
 void setEscapeForHtml(boolean htmlEscape)
          This attribue will cause the content of labels to be escaped when the value if true.
 void setExpansionAction(String action)
          Sets the action used for expanding and contracting tree nodes.
 void setIconRoot(String iconRoot)
          This will set the location of the icon images.
 void setImageRoot(String imageRoot)
          Sets the name of the directory containing the images.
 void setItemIcon(String itemIcon)
          Sets the default icon for TreeElements for a blank area of the tree.
 void setLastLineJoinImage(String lastLineJoinImage)
          Sets the image name for a blank area of the tree.
 void setLastNodeCollapsedImage(String lastNodeCollapsedImage)
          Sets the image name for a closed non-leaf node with no line below it.
 void setLastNodeExpandedImage(String lastNodeExpandedImage)
          Sets the image name for an open non-leaf node with no line below it.
 void setLineJoinImage(String lineJoinImage)
          Sets the image name for an area with a line through it.
 void setNodeCollapsedImage(String nodeCollapsedImage)
          Sets the image name for a closed non-leaf node with a line below it.
 void setNodeExpandedImage(String nodeExpandedImage)
          Sets the image name for an open non-leaf node with a line below it.
 void setRenderTagIdLookup(boolean renderTagIdLookup)
          This will cause the standard tagId to Id JavaScript to be output.
 void setRootNode(TreeElement rootNode)
          Sets the root TreeElement of this tree.
 void setRootNodeCollapsedImage(String rootNodeCollapsedImage)
          Sets the image that will be used for the root when it is Collapsed.
 void setRootNodeExpandedImage(String rootNodeExpandedImage)
          Sets the image that will be used for the root when it is Expanded.
 void setRunAtClient(boolean runAtClient)
          Cause expansion and contraction on the client.
 void setSelectedStyle(String selectedStyle)
          Set the style of a tree element when is is selected.
 void setSelectedStyleClass(String selectedStyleClass)
          Set the style class of a tree element when is is selected.
 void setSelectionAction(String action)
          Sets the action used for selecting tree nodes.
 void setSelectionTarget(String target)
          Sets the target for a selection action.
 void setTagId(String tagId)
          Set the ID of the tag.
 void setTreeStyle(String treeStyle)
          Sets the style attribute of the tree.
 void setTreeStyleClass(String treeStyleClass)
          Sets the class attribute of the tree.
 void setUnselectedStyle(String unselectedStyle)
          Set the style class of a tree element when is is not selected.
 void setUnselectedStyleClass(String unselectedStyleClass)
          Set the style class of a tree element when is is selected.
 void setVerticalLineImage(String verticalLineImage)
          Sets the image name for an area with a line through it.
 
Methods inherited from class AbstractSimpleTag
getBufferBody, getHtmlTag, getIdForTagId, 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. This action will be inherited by the TreeElements inside the tree.

Parameters:
action - - the action
Throws:
JspException

setSelectionAction

public void setSelectionAction(String action)
                        throws JspException
Sets the action used for selecting tree nodes. This action will be inherited by the TreeElements inside the tree.

Parameters:
action - - the action
Throws:
JspException

getSelectionAction

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

Returns:
the selection action name.

setSelectionTarget

public void setSelectionTarget(String target)
Sets the target for a selection action. This can specify the name of the frame where the document is to be opened.

Parameters:
target - - the target for selection

setTagId

public void setTagId(String tagId)
              throws JspException
Set the ID of the tag. This is required and will not generate the standard JavaScript lookup code unless RenderTagIdLookup is set to true.

Parameters:
tagId - - the tagId.
Throws:
JspException

setLastNodeExpandedImage

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

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

setNodeExpandedImage

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

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

setLastNodeCollapsedImage

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

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

setNodeCollapsedImage

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

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

setLastLineJoinImage

public void setLastLineJoinImage(String lastLineJoinImage)
Sets the image name for a blank area of the tree. (Defaults to "lastLineJoin.gif").

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

setItemIcon

public void setItemIcon(String itemIcon)
Sets the default icon for TreeElements for a blank area of the tree. (Defaults to "folder.gif").

Parameters:
itemIcon - - the image name of the itemIcon

setLineJoinImage

public void setLineJoinImage(String lineJoinImage)
Sets the image name for an area with a line through it. (Defaults to "lineJoin.gif").

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

setVerticalLineImage

public void setVerticalLineImage(String verticalLineImage)
Sets the image name for an area with a line through it. (Defaults to "verticalLine.gif").

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

setImageRoot

public void setImageRoot(String imageRoot)
Sets the name of the directory containing the images. This should be specified absolutely within the webapp. This target will provide images for the structure of the tree. If the iconRoot is not set, then this will also specify where the icons come are found.

Parameters:
imageRoot - - the directory name

setIconRoot

public void setIconRoot(String iconRoot)
This will set the location of the icon images. When the location is explicitly set, this works exactly the same as all other inheritable properties. When this is not set, it will return the getImageRoot location.

Parameters:
iconRoot - - the directory name for the icons

setRootNodeCollapsedImage

public void setRootNodeCollapsedImage(String rootNodeCollapsedImage)
Sets the image that will be used for the root when it is Collapsed. The root must implement ITreeRootElement to support this.

Parameters:
rootNodeCollapsedImage - - the image representing a root that is collapsed.

setRootNodeExpandedImage

public void setRootNodeExpandedImage(String rootNodeExpandedImage)
Sets the image that will be used for the root when it is Expanded. The root must implement ITreeRootElement to support this.

Parameters:
rootNodeExpandedImage - - the image representing a root that is expanded.

setRunAtClient

public void setRunAtClient(boolean runAtClient)
Cause expansion and contraction on the client. When this is set, the expand and collapse events will be handled on the client. TreeElements which are hidden becauses other TreeElements are collapsed will be rendered to the page and then displayed by JavaScript on the page. These expansion and contraction events will not call the server's expansion action.

Parameters:
runAtClient -

setEscapeForHtml

public void setEscapeForHtml(boolean htmlEscape)
This attribue will cause the content of labels to be escaped when the value if true. The default value is false.

Parameters:
htmlEscape -

setRenderTagIdLookup

public void setRenderTagIdLookup(boolean renderTagIdLookup)
This will cause the standard tagId to Id JavaScript to be output. For most of the HTML tags this is automatically output. For the tree, because the tagId is a required attribute, we make javascript support optional.

Parameters:
renderTagIdLookup -

setRootNode

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

Parameters:
rootNode - - the root treeNode

getRootNode

public TreeElement getRootNode()
Return the root node of the tree.

Returns:
returns the root node of the tree.

setSelectedStyle

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

Parameters:
selectedStyle -

setDisabledStyleClass

public void setDisabledStyleClass(String disableStyleClass)
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:
disableStyleClass -

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 -

setSelectedStyleClass

public void setSelectedStyleClass(String selectedStyleClass)
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:
selectedStyleClass -

setUnselectedStyle

public void setUnselectedStyle(String unselectedStyle)
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:
unselectedStyle -

setUnselectedStyleClass

public void setUnselectedStyleClass(String unselectedStyleClass)
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:
unselectedStyleClass -

setTreeStyle

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

Parameters:
treeStyle - - the style

setTreeStyleClass

public void setTreeStyleClass(String treeStyleClass)
Sets the class attribute of the tree. This will be set on the containing <div> for the tree.

Parameters:
treeStyleClass - - the style

setDataSource

public void setDataSource(String dataSource)
Sets an expression which indentifies the TreeElement that represents the root of the tree. When the variable being bound to is not null, the body of the Tree will be ignored and the tree being bound to will be rendered. If the variable being bound to is null, then the body of the tree will be processed to create the initial tree state and the bound variable will be set. In this situation the property must support both read and write.

Parameters:
dataSource - - the tree attribute name

setAttribute

public void setAttribute(String name,
                         String value,
                         String facet)
                  throws JspException
Set an attribute value on the implementing class. The name represents the name of the attribute. The value represents the value and may contains an expression. The facet is optional and may be used by complex types to target the attribute to a sub part of the generated markup. This method may result in errors being generated.

Specified by:
setAttribute in interface IAttributeConsumer
Parameters:
name - The name of the attribute. This value may not be null or the empty string.
value - The value of the attribute. This may contain an expression.
facet - The name of a facet to which the attribute will be applied. This is optional.
Throws:
JspException - A JspException may be thrown if there is an error setting the attribute.

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

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(HttpServletRequest request,
                                   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 -