7 Replies Latest reply on Jan 20, 2011 3:51 AM by testvogel

    How to get treeNodeKey @ rich:tree

    testvogel

      Hi,

       

      I wanna use the clickTreeNodeHandle(treeNodeKey, treeNodeId) method but I don't know how to get the treeNodeKey.

      For example I get a TreeHandle with

       

               richclient.getTreeHandle("adminNaviForm:groupTree", "groupNodeName", "JSFUnitTestGroup1")

       

      Code for the tree:

       

               <rich:tree id="groupTree"
                      value="#{groupTree.rootJobGroup}"
                      var="node"
                      eventsQueue="global"
                      requestDelay="100"
                      ignoreDupResponses="true"
                      reRender="content,activity"
                      nodeSelectListener="#{groupTree.selectionListener}"
                      ajaxSubmitSelection="true"
                      icon="/img/folder.png"
                      iconLeaf="/img/folder_page_white.png"
                      componentState="#{groupTree.treeState}">
                      <rich:treeNode id="groupTreeNode" ignoreDupResponse="true">
                          <h:outputText id="groupNodeName" value="#{node.name}" title="#{node.name}"/>
                      </rich:treeNode>
                  </rich:tree>

       

      So I think the treeNodeId is "groupTreeNode", but I don't know the treeNodeKey.

       

      Regards,

      Ole

        • 1. Re: How to get treeNodeKey @ rich:tree
          testvogel

          Hi,

           

          I can get the nodeKey with

           

          richclient.getTreeNodeByText("adminNaviForm:groupTree", "groupNodeName", "JSFUnitTestGroup1").getId();

           

          Now I have the problem that the following method

           

          richclient.clickTreeNodeHandle(richclient.getTreeNodeByText("adminNaviForm:groupTree", "groupNodeName", "JSFUnitTestGroup1").getId(), "groupTreeNode");
          

           

          throws an exception:

           

          No component ID was found for :adminNaviForm:groupTree:6::groupNodeName::groupTreeNode:handle

           

          The problem is the leading ":"

          Is this a bug in the richfaces client implementation or did I a mistake?

           

          Regards,

          Ole

          • 2. Re: How to get treeNodeKey @ rich:tree
            testvogel

            Hi,

             

            I've also problems with a normal selection of a treeNode

             

            getTreeNodeByText(".....") returns an HtmlElement with id adminNaviForm:groupTree:2::groupNodeName. That should be ok, but if I execute click I get an exception that von active event context was found.

             

            Here my rich:tree

             

             

                     <rich:tree id="groupTree"
                            value="#{groupTree.rootJobGroup}"
                            var="node"
                            eventsQueue="global"
                            requestDelay="100"
                            ignoreDupResponses="true"
                            reRender="content,activity"
                            nodeSelectListener="#{groupTree.selectionListener}"
                            ajaxSubmitSelection="true"
                            icon="/img/folder.png"
                            iconLeaf="/img/folder_page_white.png"
                            componentState="#{groupTree.treeState}">
                            <rich:treeNode id="groupTreeNode" ignoreDupResponse="true">
                                <h:outputText id="groupNodeName" value="#{node.name}" title="#{node.name}"/>
                            </rich:treeNode>
                        </rich:tree>
            
            • 3. Re: How to get treeNodeKey @ rich:tree
              testvogel

              So...

               

              I've also traced all events with Firebug, but there is no more than

               

              mousemove

              mousedown

              POST ....

              mouseup

               

              But this is not working in my tests. Any ideas???

               

                   HtmlElement groupNode = richclient.getTreeNodeByText("adminNaviForm:groupTree",
                              "groupNodeName", "Test");

              groupNode.click();

               

               

               

              edit: The problem is that the #{groupTree.selectionListener} is never called. Why??? The click on the node is ignored by jsfunit / htmlunit and I dont understand why :/

              • 4. Re: How to get treeNodeKey @ rich:tree
                ssilvert

                It's hard to say without a lot of analysis, but I can offer some tips for figuring it out.  One is to just make sure that groupNode is really the HTML node that is meant to be clicked.  You can output the declaration of that tag by just saying System.out.println(groupNode.toXML()).

                 

                Also, there is this bug if you (or some component) uses <a4j:queue>.  https://issues.jboss.org/browse/JSFUNIT-236

                 

                Stan

                • 5. Re: How to get treeNodeKey @ rich:tree
                  testvogel

                  Hi,

                   

                  the HTML code:

                   

                  <table border="0" cellpadding="0" cellspacing="0" class="dr-tree-full-width rich-tree-node" id="adminNaviForm:groupTree:2::groupTreeNode">
                    <tbody align="left">
                      <tr id="adminNaviForm:groupTree:2::groupTreeNode:mainRow" onclick=" ">
                        <td class="dr-tree-h-ic rich-tree-node-handleicon dr-tree-h-ic-line-last" id="adminNaviForm:groupTree:2::groupTreeNode:handles">
                          <div>
                            <img alt="" class="dr-tree-h-ic-img-md dr-tree-h-ic-img" id="adminNaviForm:groupTree:2::groupTreeNode:handle:img" src="/jontram/a4j/g/3_3_1.GAimages/spacer.gif"/>
                            <input class="dr-tree-h-input" id="adminNaviForm:groupTree:2::groupTreeNodeNodeExpanded" name="adminNaviForm:groupTree:2::groupTreeNodeNodeExpanded" type="hidden" value="false"/>
                          </div>
                        </td>
                        <td class="dr-tree-h-ic rich-tree-node-icon-leaf dr-tree-h-ic-line-clp" id="adminNaviForm:groupTree:2::groupTreeNode:icon" rich:ajaxselectedlistener="ajax_selected_listener_flag" rich:draggableoptions="{'parameters':{'dragSourceId':'adminNaviForm:groupTree:2::groupTreeNode','adminNaviForm:groupTree:2::groupTreeNode':'adminNaviForm:groupTree:2::groupTreeNode'} } " rich:dropzoneoptions="{} ">
                          <img alt="" class="dr-tree-h-ic-img-md dr-tree-h-ic-img" src="/jontram/img/folder_page_white.png"/>
                        </td>
                        <td class="dr-tree-h-text rich-tree-node-text" id="adminNaviForm:groupTree:2::groupTreeNode:text" rich:highlightedclass="dr-tree-i-hl rich-tree-node-highlighted" rich:selectedclass="dr-tree-i-sel rich-tree-node-selected">
                          <span id="adminNaviForm:groupTree:2::groupNodeName" title="Test">
                            Test
                          </span>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                  
                  

                   

                  edit:

                   

                  In the deployed application the tree is working fine and the node listener is called properly.

                  The

                  adminNaviForm:groupTree:2::groupNodeName

                  component has no active event context.

                  If I'm using h:commandLink instead of h:outputText the click is working properly but the application is broken. I only get redirected to an error page with many conversation errors. Any idea?

                   

                  edit 2:

                   

                  In my rendered html code I also see a javascript which should be executed:

                   

                   

                  <script type="text/javascript">
                  //<![CDATA[
                  (function() {
                              var tree = new Tree("adminNaviForm:groupTree", "adminNaviForm:groupTree:input", "ajax",
                                  {
                                      onselect: "", 
                                      onexpand: "", 
                                      oncollapse: "",
                                      oncontextmenu: "" 
                                  },
                                  function(event) {
                                      A4J.AJAX.Submit('bodyRegion','adminNaviForm',event,{'ignoreDupResponses':true,'similarityGroupingId':'adminNaviForm:groupTree','parameters':{'adminNaviForm:groupTree:selectedNode':event.selectedNode} ,'eventsQueue':'global','requestDelay':100,'actionUrl':'/jontram/pages/admin/jobs/job.group.seam'} ); return false;
                                  },
                                  {'showConnectingLines':true} 
                              );
                              tree.drop = function(event,drag){var options = {'ignoreDupResponses':true,'similarityGroupingId':'adminNaviForm:groupTree','parameters':{'adminNaviForm:groupTree':'adminNaviForm:groupTree'} ,'eventsQueue':'global','requestDelay':100,'actionUrl':'/jontram/pages/admin/jobs/job.group.seam'} ;options.parameters['dropTargetId'] = 'adminNaviForm:groupTree';Object.extend(options.parameters, drag.getParameters());var dzOptions = this.getDropzoneOptions(); if (dzOptions.ondrop) { if (!dzOptions.ondrop.call(this, event)) return; };A4J.AJAX.Submit('bodyRegion','adminNaviForm',event,options);};
                          }());
                  //]]>
                    </script>
                  
                  
                  

                   

                  Maybe someone has a hint why this javascript is never called. I think the A4J.AJAX.Submit(...) should be called to get my tree tests working.

                   

                  edit3:

                   

                  If I refresh the page the selectedNodeHandler will be called but this should not the solution why no event in the tests is calling the handler.

                  • 6. Re: How to get treeNodeKey @ rich:tree
                    testvogel

                    Maybe someone has any debug hints?

                    • 7. Re: How to get treeNodeKey @ rich:tree
                      testvogel

                      Hi all,

                       

                      I've fixed the main bug. The problem is that something in HTMLUnit / JSFUnit always throw an RuntimeException like this:

                       

                      ERROR [JavaScriptJobManagerImpl] Job run failed with unexpected RuntimeException: No active event context

                       

                      but there is an active event context on this component. If I click on something in the tree (handler, node,...) I always get this exception.

                      The solution is to click on a node, go to any other view and then go back to the view with the tree (rejoin the conversation). This is working if I click on a node, but it's not working for the handler components.

                       

                      I get the handler with

                       

                      HtmlElement handler = richclient.getTreeHandle("adminNaviForm:groupTree", "groupTreeNode", parentGroup);

                      System.out.println(handler.isDisplayed());

                      System.out.println(handler.asXml());

                       

                      isDisplayed returns true

                      asXml returns

                       

                       

                      09:39:34,923 INFO  [STDOUT] <a class="rich-tree-node-handle" href="#" id="adminNaviForm:groupTree:35::groupTreeNode:handle" onclick="var c = Tree.Item.findComponent(this); if (!c) return; c.fireExpansionEvent();;A4J.AJAX.Submit('bodyRegion','adminNaviForm',event,{'ignoreDupResponses':true,'similarityGroupingId':'adminNaviForm:groupTree:35::groupTreeNode','parameters':{'adminNaviForm:groupTree:35::groupTreeNodeNodeExpanded':'true','adminNaviForm:groupTree:35::groupTreeNodeAjaxExpanded':true} ,'eventsQueue':'global','requestDelay':100,'actionUrl':'/pages/admin/jobs/job.group.seam'} ); return false;">
                        <img alt="" class="dr-tree-pointer-cursor dr-tree-h-ic-img-md dr-tree-h-ic-img rich-tree-node-handleicon-collapsed" id="adminNaviForm:groupTree:35::groupTreeNode:handle:img:collapsed" src="/jontram/a4j/g/3_3_1.GAorg.richfaces.renderkit.html.images.TreePlusImage/DATB/eAH7!!!!72fX3N3dASdTBoo_" style=";border:0"/>
                        <img alt="" class="dr-tree-pointer-cursor dr-tree-h-ic-img-md dr-tree-h-ic-img rich-tree-node-handleicon-expanded" id="adminNaviForm:groupTree:35::groupTreeNode:handle:img:expanded" src="/jontram/a4j/g/3_3_1.GAorg.richfaces.renderkit.html.images.TreeMinusImage/DATB/eAH7!!!!72fX3N3dASdTBoo_" style="display: none;;border:0"/>
                      </a>
                      

                       

                      It looks fine

                       

                      But now the problem is when I click on the handler something is happening. I know this because I have a ajax processing component on my view and check this, but the AjaxController does nothing The trick to rejoin the conversation doesnt work

                       

                      Maybe a solution is to wait until the processing is finished (something like waitFor(!processing.isDisplayed()) - this would be the solution in selenium)

                       

                      Any solution or hints?

                       

                      greets,

                      ole