5 Replies Latest reply on Feb 4, 2010 1:11 PM by ssilvert

    New <rich:tree> support.  Try it out now!

    ssilvert

      I've just creted a few new methods for the RichFacesClient that help you manipulate a <rich:tree>.

       

      JSFUnitWithRichFaces  I've also uploaded the snapshot to the JBoss snapshot repo.

       

      I'd love to get some alpha testers looking at this.  It relies heavily on XPath queries and it's hard to know what HTML might be thrown at those queries.  So I want to make sure they are solid before the JSFUnit 1.2 release.

       

      Enjoy!

       

      Stan

        • 1. Re: New <rich:tree> support.  Try it out now!
          ssilvert

          Also be aware that I did find this one bug.  Click here for details in the jira.

           

          I don't know how to fix it yet, but there is a workaround noted on the jira.

           

          Stan

          • 2. Re: New <rich:tree> support.  Try it out now!

            Hi Stan,

             

            I installed the new rich client and tried the getTreeNodeByText() and GetTreeHandle() methods. They seem to work fine on the top level node I can resolve the node using the getTreeNodeByText and then click it and fire a selection event and I can also use the getTreeHandle() method and expand the node that way.

             

            The problem I am running into is in trying to continue expanding the tree. The first child and any other nodes under it do not respond to any clicked event. I verified that the child node is found (once the Parent node is expanded) and I was able to resolve to it using the getTreeNodeByText() method, but then when I click on the node  I don't get the expected event to fire and post and Ajax request to the server.

             

            Everything works as expected in the IE 7  - does not work and no error is returned from the JSFUnit.

             


            Here is the tree definition.

             

            <rich:tree id="CS_TREE"
                        switchType="ajax"
                        value="#{backingBean.categoryTreeData}" var="item"
                        ajaxSubmitSelection="true" limitToList="true"
                        nodeFace="#{item.type}"
                        nodeSelectListener="#{backingBean.actionTreeNodeSelected}"
                        reRender="ID_DETAIL_VIEW_CONTAINER,ID_COMMAND_BUTTONS,ID_MD_DELETE,MSG,CS_TREE"
                        binding="#{backingBean.uiTree}">
                               
                        <rich:treeNode id="S_NODE" type="SchemeNodeType"
                            icon="/images/scheme-new.png" iconLeaf="/images/scheme-new.png"
                            ignoreDupResponses="true"
                            nodeClass="treeNode">
                                <a4j:support event="ondblclick"
                                    actionListener="#{backingBean.actionExpandTreeNode}"
                                    reRender="CS_TREE,SEARCH_PANEL,SEARCH_MSG"/>
                               
                                <f:facet name="iconCollapsed">
                                    <h:graphicImage id="plusSchemeNode" value="/images/Plus.gif" />
                                </f:facet>
                                <f:facet name="iconExpanded">
                                    <h:graphicImage id="minusSchemeNode" value="/images/Minus.gif" />
                                </f:facet>
                               
                                <h:outputText id="S_NODE_NAME" value="#{item.longNameWithStatus}"  />   
                        </rich:treeNode>
                       
                        <rich:treeNode id="C_NODE" type="CategoryNodeType"
                            icon="/images/category-new.png"
                            iconLeaf="/images/category-new.png"
                            nodeClass="treeNode"
                            ignoreDupResponses="true">
                            <a4j:support event="ondblclick"
                                actionListener="#{backingBean.actionExpandTreeNode}"
                                reRender="CS_TREE,SEARCH_PANEL,SEARCH_MSG"/>
               
                                <f:facet name="iconCollapsed">
                                    <h:graphicImage id="plusCategoryNode" value="/images/Plus.gif" />
                                </f:facet>
                                <f:facet name="iconExpanded">
                                    <h:graphicImage id="minusCategoryNode" value="/images/Minus.gif" />
                                </f:facet>

             

                                <h:outputText value="#{item.longNameWithStatus}" />
                        </rich:treeNode>
                    </rich:tree>

             

             

            Here is my Test method.

             

            public void testTreeNavigation() throws IOException{
                   
                   
                    HtmlElement sNode = richClient.getTreeHandle("CS_TREE", "S_NODE", "Topaz Products");
                    sNnode.click();

                   

                    HtmlElement cNnode = richClient.getTreeNodeByText("CS_TREE", "C_NODE", "Quartz R4");

             

                   Works fine to this point.

             

                    cNnode.click(); <--- This click does nothing. can't expand to tree to anymore levels.

                  ...... more test code and assertions.


                   
                }

            • 3. Re: New <rich:tree> support.  Try it out now!
              ssilvert

              Hi Rudy,

               

              Thanks for help with alpha testing.  I have tested this myself on a tree that is three levels deep, so I know that the nesting itself is not the problem.  There could be something different about your particular tree.

               

              I noticed that your tree responds to ondblclick but you are only doing a single click in your test.  Perhaps you really mean to call cNnode.dblClick() ?

               

              Stan

              • 4. Re: New <rich:tree> support.  Try it out now!

                Stan, thank you for your response.

                 

                Perhaps it is something with this particular tree then, although I am not sure what that might be.

                 

                I did try cNode.dblClick() and was still not able to expand the tree node successfully. Also, it is not just double clicking and expanding of the second node that does not work but clicking on the second node should fire the tree node selection event that is configured for the tree itself and that is not happening.

                 

                It is behaving as if the Ajax support is not in place for anything but the root node. When I single click on the root node I do get the tree node selection event to fire. Also, single clicking any node in an actual browser session does fire the node selection event as expected.

                 

                -- Rudy

                • 5. Re: New <rich:tree> support.  Try it out now!
                  ssilvert

                  Hi Rudy,

                   

                  I looked at this a little more and realized that you are probably passing in the wrong parameter.  The documentation was wrong for getTreeNodeByText().  I've updated the JSFUnitWithRichFaces wiki page.

                   

                  So you should add an id attribute to your h:outputText, such as id="longNameWithStatus" and your method call should be:

                   

                  HtmlElement cNnode = richClient.getTreeNodeByText("CS_TREE", "longNameWithStatus", "Quartz R4");

                   

                  You can see if richClient found the correct HTML element if you just say System.out.println(cNnode.asXml());

                   

                  Please let me know if that works.  If not, you can debug this with FireBug and the FireXPath extension.  getTreeNodeByText() uses this xpath statement:

                   

                  //text()[. = 'myText']/parent::*[contains(@id,'myTreeId')][contains(@id,'myComponentId')]

                   

                  If you fill in the params from getTreeNodeByText() with that xpath then it should find the correct node.  Let me know if you need help with that too.  Thanks again for alpha testing.  It's paying off.

                   

                  Stan