<?xml version='1.0' encoding='UTF-8'?>
<section>
  <sectioninfo>
    <keywordset>
      <keyword>node</keyword>
      <keyword>rich:treeNode</keyword>
      <keyword>HtmlTreeNode</keyword>
    </keywordset>
  </sectioninfo>

  <table>
    <title>Component identification parameters </title>
    <tgroup cols="2">
      <thead>
        <row>
          <entry>Name</entry>
          <entry>Value</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>component-type</entry>
          <entry>org.richfaces.TreeNode</entry>
        </row>
        <row>
          <entry>component-class</entry>
          <entry>org.richfaces.component.html.HtmlTreeNode</entry>
        </row>
        <row>
          <entry>component-family</entry>
          <entry>org.richfaces.TreeNode</entry>
        </row>
        <row>
          <entry>renderer-type</entry>
          <entry>org.richfaces.TreeNodeRenderer</entry>
        </row>
        <row>
          <entry>tag-class</entry>
          <entry>org.richfaces.taglib.TreeNodeTag</entry>
        </row>
      </tbody>
    </tgroup>
  </table>

  <section>
    <title>Creating the Component with a Page Tag</title>
    <para>Here is a simple example as it could be used on a page: </para>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="XML"><![CDATA[...
    <rich:tree ... faceNode="simpleNode">
        <rich:treeNode type="simpleNode">
            <!--Tree node data displaying template-->
        </rich:treeNode>
    </rich:tree>
...
]]></programlisting>
  </section>
  <section>
    <title>Creating the Component Dynamically Using Java</title>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="JAVA"><![CDATA[import org.richfaces.component.html.HtmlTreeNode;
...
HtmlTreeNode myPanel = new HtmlTreeNode();
...
]]></programlisting>
  </section>
  
  <section>
    <title>Details of Usage</title>
    <para>As it has been mentioned <link linkend="treeNode">above</link>, <property>treeNode</property> defines a template for nodes
      rendering in a tree. Thus, during XML document rendering (a web.xml application) as a tree,
      the following nodes output (passed via var=&quot;data&quot; on a tree) happens:</para>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="XML"><![CDATA[...
    <rich:tree ... faceNode="simpleNode" ... value="#{bean.data}" var="data">
        <rich:treeNode type="simpleNode">
            <h:outputText value="context-param:"/>
            <h:inputText value="#{data.name}"/>
        </rich:treeNode>
    </rich:tree >
...
]]></programlisting>
    <figure>
      <title>Nodes output</title>
      <mediaobject>
        <imageobject>
          <imagedata fileref="images/treeNode2.png"/>
        </imageobject>
      </mediaobject>
    </figure>
    <para>Hence, outputText outputs the &quot;context-param&quot; string and then the input
      is output for the data.name element of this node.</para>
    <para>Different nodes for rendering could be defined depending on some conditions on the tree
      level. Each condition represents some rendering template. To get more information on various
        <property>treeNodesAdaptorAdaptor</property> definition for nodes, <link linkend="tree">see the tree
        component chapter</link>.</para>
    <para>Switching between expanded/collapsed modes is also managed on the tree level and defined
      in <link linkend="tree">the corresponding section</link>.</para>
    <para>Default nodes of the tree level as well as ones defined with the
      <property>treeNodesAdaptorAdaptor</property> component could send Ajax requests when selected with the
      mouse, it&apos;s managed with the <emphasis>
        <property>&quot;ajaxSubmitSelection&quot;</property>
      </emphasis> attribute (true/false).</para>
    <para> The <emphasis>
      <property>&quot;icon&quot;</property>
    </emphasis>, <emphasis>
      <property>&quot;iconCollapsed&quot;</property>
    </emphasis>, <emphasis>
      <property>&quot;iconExpanded&quot;</property>
    </emphasis>, <emphasis>
      <property>&quot;iconLeaf&quot;</property>
    </emphasis> attributes define icons for the component. Also you can define icons using facets
      with the same names. If the facets are defined, the corresponding attributes are ignored and
      facets contents are used as icons. By default the width of a rendered facet area is 16px. </para>
    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    
    <programlisting role="JAVA"><![CDATA[...
    <rich:tree ....>
        ...
        <f:facet name="icon">
            <h:graphicImage value="/images/tree/singer.png "/>
        </f:facet>
        <f:facet name="iconCollapsed">
            <h:graphicImage value="/images/tree/singer.png " />
        </f:facet>      
        <f:facet name="iconExpanded">
            <h:graphicImage value="/images/tree/singer.png " />
        </f:facet>
        <f:facet name="iconLeaf">
            <h:graphicImage value="/images/tree/song.png " />
        </f:facet>
          ...
    </rich:tree>
...]]></programlisting>
  </section>
  <section>
    <title>Built-in Drag and Drop</title>
    <para>The main information on Drag and Drop operations is given in <link linkend="tree">the
        corresponding paragraph</link> of the <property>tree</property> component chapter.
      It&apos;s only necessary to mention that each node could also be a Drag element as well as
      a Drop container, i.e. the container and the element have all attributes, listeners and ways
      of behavior similar to the ones of the <emphasis role="bold">
        <property>&lt;rich:draggable&gt;</property>
      </emphasis> and <emphasis role="bold">
        <property>&lt;rich:dropZone&gt;</property>
      </emphasis> components simultaneously.</para>
  </section>
  <section>
    <title>Events Handling</title>
    <para>Just as Drag and Drop operations it corresponds to the one described on <link
        linkend="tree">the tree component level</link> for a default Node.</para>
  </section>
  <section>
    <title>Look-and-Feel Customization</title>
    
    <para>For skinnability implementation, the components use a <emphasis>
      <property>style class redefinition method.</property>
    </emphasis> Default style classes are mapped on <emphasis>
      <property>skin parameters.</property>
    </emphasis></para>
    
    <para>There are two ways to redefine the appearance of all <emphasis role="bold">
      <property>&lt;rich:treeNode&gt;</property>
    </emphasis> components at once:</para>
    
    <itemizedlist>
      <listitem>
        <para>Redefine the corresponding skin parameters</para>
      </listitem>
      
      <listitem>
        <para>Add to your style sheets <emphasis>
          <property>style classes</property>
        </emphasis> used by a <emphasis role="bold">
          <property>&lt;rich:treeNode&gt;</property>
        </emphasis> component</para>
      </listitem>
    </itemizedlist>
  </section>
  
  <section id="SPRofTN">
    <title>Skin Parameters Redefinition</title>
    <table>
      <title>Skin parameters for a node element</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Skin parameters</entry>
            <entry>CSS properties</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>panelTextColor</entry>
            <entry>color</entry>
          </row>
          <row>
            <entry>preferableDataSizeFont</entry>
            <entry>font-size</entry>
          </row>
          <row>
            <entry>preferableDataFamilyFont</entry>
            <entry>font-family</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
    <table>
      <title>Skin parameters for a selected element</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Skin parameters</entry>
            <entry>CSS properties</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>headerBackgroundColor</entry>
            <entry>border-color</entry>
          </row>
          <row>
            <entry>panelTextColor</entry>
            <entry>color</entry>
          </row>
          <row>
            <entry>selectControlColor</entry>
            <entry>color</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
    <table>
      <title>Skin parameters for a mouseovered element</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Skin parameters</entry>
            <entry>CSS properties</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>selectControlColor</entry>
            <entry>color</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </section>
  
  <section>
    <title>Definition of Custom Style Classes</title>
    <para>On the screenshot there are classes names that define styles for component elements.</para>
    
    <figure>
      <title>Classes names</title>
    <mediaobject>
      <imageobject>
        <imagedata fileref="images/treeNode3.png"/>
      </imageobject>
    </mediaobject>
    </figure>
    
    <table>
      <title>Classes names that define a node element</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Class name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>rich-tree-node</entry>
            <entry> Defines styles for a tree node</entry>
          </row>

          <row>
            <entry>rich-tree-node-handleicon</entry>
            <entry>Defines styles for a tree node handleicon</entry>
          </row>
     
          <row>
            <entry>rich-tree-node-children</entry>
            <entry>Defines styles for all tree node subnodes</entry>
          </row>
          <row>
            <entry>rich-tree-node-text</entry>
            <entry>Defines styles for a tree node text</entry>
          </row>
          <row>
            <entry>rich-tree-node-icon</entry>
            <entry>Defines styles for a tree node icon</entry>
          </row>
          <row>
            <entry>rich-tree-node-icon-leaf</entry>
            <entry>Defines styles for a tree node icon leaf</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
    
    <table>
      <title>Classes names that define states for a node element</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Class name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
         
          <row>
            <entry>rich-tree-node-selected</entry>
            <entry>Defines styles for a selected tree node </entry>
          </row>
          <row>
            <entry>rich-tree-node-highlighted</entry>
            <entry>Defines styles for a highlighted tree node </entry>
          </row>
          
          <row>
            <entry>rich-tree-node-handleicon-collapsed</entry>
            <entry>Defines styles for a collapsed tree node handleicon </entry>
          </row>
          <row>
            <entry>rich-tree-node-handleicon-expanded</entry>
            <entry>Defines styles for a expanded tree node handleicon</entry>
          </row>
         
        </tbody>
      </tgroup>
    </table>
    
    <para>In order to redefine the style for all <emphasis role="bold">
      <property>&lt;rich:treeNode&gt;</property>
    </emphasis> components on a page using CSS, it&apos;s enough to create classes with the
      same names and define the necessary properties in them.</para>
    
    <para>To change the style of particular <emphasis role="bold">
      <property>&lt;rich:treeNode&gt;</property>
    </emphasis> components define your own style classes in the corresponding <emphasis
      role="bold">
      <property>&lt;rich:treeNode&gt;</property>
    </emphasis>attributes.</para>
    <para>It is also possible to change look and feel of specific <emphasis role="bold"><property>&lt;rich:treeNode&gt;</property>
    </emphasis> with the help of defining for them <emphasis>
        <property>&quot;selectedClass&quot;</property>
      </emphasis> and <emphasis>
        <property>&quot;highlightedClass&quot;</property>
      </emphasis> attributes by their specific classes.</para>
  </section>

  <section>
    <title>Relevant Resources Links</title>
    <para>How to Expand/Collapse Tree Nodes from code see <ulink
        url="http://labs.jboss.com/wiki/ExpandCollapsetreeNodesAdaptor">here</ulink>. </para>
  </section>
</section>
