Class TreeIconTag

  • All Implemented Interfaces:
    ConditionalTag, IconSupport, org.apache.commons.jelly.Tag

    public class TreeIconTag
    extends FormBaseTag
    implements IconSupport

    A tag for defining icons for tree components.

    Tags of this type can be placed in the body of a TreeTag . A TreeIconTag must be passed an icon name and the corresponding icon (which is usually specified by a nested IconTag). It collects this data and invokes the addIcon() method of the TreeTag.

    The following fragment demonstrates how this tag can be used for changing the default icons of a tree component:

     <f:tree model="myTreeModel" name="myTree">
       <f:treeIcon name="LEAF">
         <f:icon resource="myLeafIcon.gif"/>
       </f:treeIcon>
       <f:treeIcon name="BRANCH_EXPANDED">
         <f:icon resource="myExpandedIcon.gif"/>
       </f:treeIcon>
       <f:treeIcon name="BRANCH_COLLAPSED">
         <f:icon resource="myCollapsedIcon.gif"/>
       </f:treeIcon>
     </f:tree>
     

    The names of the icons must correspond with the TreeIconHandler used by the tree component. The icon handler returns icon names for the nodes of the tree. These names must exactly match the icon names passed to the name attribute of the TreeIconTag. In the example above the names used by the default icon handler are used. If a custom icon handler is used the names may have to be adapted.

    The following table displays the attributes supported by this tag:

    Attribute Description Optional
    name Defines the name of the icon. Each icon is associated with a name. No

    Both an icon and an icon name must be provided otherwise an exception will be thrown.

    Version:
    $Id: TreeIconTag.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • TreeIconTag

        public TreeIconTag()
    • Method Detail

      • getName

        public String getName()
        Returns the name of the icon.
        Returns:
        the icon name
      • setName

        public void setName​(String name)
        Sets the name of the icon. This is the set method of the name attribute.
        Parameters:
        name - the icon name
      • getIcon

        public Object getIcon()
        Returns the icon.
        Returns:
        the icon
      • setIcon

        public void setIcon​(Object icon)
        Sets the icon. This method is intended to be called by tags in the body of this tag.
        Specified by:
        setIcon in interface IconSupport
        Parameters:
        icon - the icon
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this tag. This implementation tests whether all required properties are set. Then it adds the icon to the parent tree tag.
        Specified by:
        process in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is used incorrectly
        FormBuilderException - if an error occurs