5 Replies Latest reply on Nov 22, 2010 5:02 AM by ilya_shaikovsky

    rich tree not working after

    arul002

      Hi,

       

      I am new to richfaces and tried using the tree in this livedemo link - http://ludvigsens.net/richfaces-3.3.2/richfaces/tree.jsf?tab=model&cid=107033

       

      This tree is working fine when switchType is client. If you change the switchType to ajax/server, expanding and collapsing a tree node is not working after selecting one of its child node.

       

      I searched for this issue in the forum but couldnt able to find one except this http://community.jboss.org/message/35257#35257 but no asolution is there.

       

      Anyone already faced this issue? I am using richfaces 3.3.1.GA version in my project. Please help.

        • 1. Re: rich tree not working after
          ilya_shaikovsky

          please show sources and check for JS errors.

          • 2. Re: rich tree not working after
            arul002

            Ilya Shaikovsky wrote:

             

            please show sources and check for JS errors.

            All the source files are available in the richfaces livedemo http://ludvigsens.net/richfaces-3.3.2/richfaces/tree.jsf?tab=model&cid=107033.

             

            Still here it is,

            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:a4j="http://richfaces.org/a4j"
                   xmlns:rich="http://richfaces.org/rich">
                  <style>
                     .col, .col2 {
                         width:50%;
                         vertical-align:top;
                     }
                 </style>
                  <h:form>   
                     <h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
                          <rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
                             reRender="selectedNode" ajaxSubmitSelection="true"  switchType="ajax"
                             value="#{simpleTreeBean.treeNode}" var="item" ajaxKeys="#{null}">
                         </rich:tree>

                      <h:outputText escape="false" value="Selected Node: #{simpleTreeBean.nodeTitle}" id="selectedNode" />
                   </h:panelGrid>
                  </h:form>
            </ui:composition>

             

            Managed bean - simpleTreeBean is also available in the same livedemo page.

            • 3. Re: rich tree not working after
              ilya_shaikovsky

              I tried that on my local demo and works fine. Please consider checking on latest version.

              • 4. Re: rich tree not working after
                arul002

                Hi,

                 

                The issue is with tree.getRowData() in processSelection method. It gives IllegalStateException whenever I expand/collapse a node after selecting one of its child node. There must be a better solution but if I just catch this exception-do nothing, then everything's working fine.

                 

                 

                public void processSelection(NodeSelectedEvent event) {
                        HtmlTree tree = (HtmlTree) event.getComponent();
                        Object rowKey = tree.getRowKey();
                //        try {
                nodeTitle = (String) tree.getRowData(rowKey);
                selectedNodeChildren.clear();
                TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
                /*} catch (IllegalStateException e) {
                e.printStackTrace();
                }*/

                public void processSelection(NodeSelectedEvent event) {

                             HtmlTree tree = (HtmlTree) event.getComponent();

                             Object rowKey = tree.getRowKey();

                             try {

                                nodeTitle = (String) tree.getRowData(rowKey);

                                selectedNodeChildren.clear();

                                TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());

                           } catch (IllegalStateException e) {

                                e.printStackTrace();

                           }

                }

                 

                Ilya Shaikovsky wrote:

                 

                I tried that on my local demo and works fine. Please consider checking on latest version.

                 

                Could you please tell me the version of richfaces you tried. I tried it in 3.3.3.Final but still the problem exists - java.lang.IllegalStateException - No tree element available or row key not set!

                • 5. Re: rich tree not working after
                  ilya_shaikovsky

                  Yup, I could see the exception now also. But it not prevents the tree from working in my case, so I not found from the beginning. And it seems - catching the exception is the only way. It's looks like an issue in component but as we have no plans for 3.3.x branch releases - please use workaround.