9 Replies Latest reply on Oct 16, 2007 4:23 PM by j-pro

    nodeSelectListener: WARN lifecycle NP Exception + JScript er

    j-pro

      Good afternoon.

      Today is a day of unresolvable errors as I see...

      I use rich:recursiveTreeNodesAdaptor and want to do some action while user clicks on the node. So for that I have:

      <h:form id="employeesDataTable_form">
      
       <rich:tree style="width:250px" styleClass="tree" switchType="ajax"
       ajaxSubmitSelection="true" showConnectingLines="true"
       stateAdvisor="#{departmentTreeStateAdvisor}"
       nodeSelectListener="#{am.onDepartmentTreeSelect}">
       <rich:recursiveTreeNodesAdaptor roots="#{amBean.departmentsTreeRoots}" var="item" nodes="#{item.nodes}" />
       </rich:tree>
      
       </h:form>


      onDepartmentTreeSelect method:
      public void onDepartmentTreeSelect(NodeSelectedEvent event)
       {
       if(event == null) { System.out.println("############### >>>>> Event IS NULL !!!"); return; }
      
       UITree tree = (UITree) event.getComponent();
      
       System.out.println("################# >>>>> Tree node selected");
      
       if(tree == null) { System.out.println("############### >>>>> Tree IS NULL !!!"); return; }
      
       TreeNode selectedNode = tree.getTreeNode();
      
       if(selectedNode.isLeaf()) System.out.println("#### > Is leaf");
       else System.out.println("#### > Is NOT leaf");
      
       Object data = selectedNode.getData();
       if(data == null) System.out.println("#### > DATA Is null");
       else System.out.println("#### > DATA Is NOT null");
      
       Iterator children = selectedNode.getChildren();
       System.out.println("#### > Children:");
      
      
       while(children.hasNext())
       {
       TreeNode tn = (TreeNode)children.next();
       if(tn.isLeaf()) System.out.println("## > Is leaf");
       else System.out.println("## > Is NOT leaf");
      
       data = tn.getData();
       if(data == null) System.out.println("###> DATA Is null");
       else System.out.println("## > DATA Is NOT null");
       }
      
       System.out.println("################# >>>>> Tree node selected FINISH");
      
       }



      Having all that, while opening the app in Firefox, I see(via Firebug) 7 errors:
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 25
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 23
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 25
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 23
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 25
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 23
      
      $ is not defined
      http://localhost:8080/HRD/a4j_3_1_0org/richfaces/renderkit/html/scripts/tree-item.js.jsf
      Line 25


      The JS code in these 23 and 25 lines is:
      ...
      
      23 this.fireExpansionEvent();},isCollapsed:function(){var e=$(this.elementID.children);if(e){return e.style.display=="none";}else{return true;}},processMouseOut:function(e){if(this.isMouseIn){this.isMouseIn=false;var eText=$(this.elementID.text);var hClass=Richfaces.getNSAttribute("highlightedclass",eText);if(hClass){var classNames=hClass.split(' ')
      
      ...
      
      25 if(window.drag){this.dragLeave(e);}}}},processMouseOver:function(e){if(!this.isMouseIn){this.isMouseIn=true;var eText=$(this.elementID.text);var hClass=Richfaces.getNSAttribute("highlightedclass",eText);if(hClass){var classNames=hClass.split(' ')
      
      ...



      And when I click on the node, all I see in console is:
      21:34:09,801 INFO [STDOUT] ################# >>>>> Tree node selected
      21:34:09,801 WARN [lifecycle] /staff.xhtml @24,69 nodeSelectListener="#{am.onDepartmentTreeSelect}": java.lang.NullPointerException



      That's all.... No stack trace or something... But in the logs is:
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase UPDATE_MODEL_VALUES 4
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase INVOKE_APPLICATION 5
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase INVOKE_APPLICATION 5
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase RENDER_RESPONSE 6
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] PhaseListener enter Before RenderView Phase with ViewId /staff.xhtml and RenderKitId HTML_BASIC
      2007-09-27 21:34:09,801 DEBUG [org.ajax4jsf.application.AjaxViewHandler] Process AJAX events to calculate areas.
      
      ...



      If i press on the node again - console outputs the same. Why does it happen? I can't find my error here... Maybe a bug?

        • 1. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
          j-pro

          Please, tell me if anybody can help me with this, or if nobody can help... then I'll try to find out other ways to solve the task...

          Sorry for asking again, just want to know if anybody can help.

          Thanks for understanding.

          • 2. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
            j-pro

            Problem solved. Thanks to Maksim.

            I've moved my managed beans in the war package. It was in my jar package - that was the reason of this exception. Now everything works fine.

            Thanks for help.

            • 3. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
              j-pro

              Hmm.. sorry, but the problems seems to be still exist...

              Yes, I've moved all needed methods and beans in war. But it still gives that:

              19:49:13,252 INFO [STDOUT] ################# >>>>> Tree node selected
              19:49:13,252 WARN [lifecycle] /staff.xhtml @25,64 nodeSelectListener="#{treeMan.onDepartmentTreeSelect}": java.lang.NullPointerException


              I can't understand why it could be, because there are conditions for null values in treeMan.onDepartmentTreeSelect.

              Can anybody help me with that?


              Here is my tree:
              <rich:tree style="width:250px" id="structureTree" styleClass="tree" switchType="ajax"
               ajaxSubmitSelection="true" showConnectingLines="true"
               changeExpandListener="#{treeMan.onDepartmentTreeExpand}"
               nodeSelectListener="#{treeMan.onDepartmentTreeSelect}"
               stateAdvisor="#{departmentTreeStateAdvisor}">
               <rich:recursiveTreeNodesAdaptor roots="#{treeMan.departmentsTreeRoots}" var="item" nodes="#{item.nodes}" />
               </rich:tree>


              onDepartmentTreeSelect method is unchanged.

              Thanks for help in advance.


              P.S.: The same is with changeExpandListener...

              • 4. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
                j-pro

                Sorry for asking again, but is there any suggestions on that problem?

                • 5. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
                  j-pro

                  Please, anybody tell me at least if I should wait for your answer here :) This silent makes me think that this topic is forgotten and the problem never can be solved... But it's very important for me.

                  Sorry for bothering...

                  • 6. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip

                    I had just started looking into richfaces, hope this helps. I refered the example from richfaces demo and think u referring the same. So if thats the case u most also be using the FileSystemNode class, in that case you should cast
                    FileSystemNode selectednode = (FileSystemNode ) tree.getRowData();

                    instead of
                    TreeNode selectedNode = tree.getTreeNode();
                    I tried your code with the richfaces demo code and got null pointer exception for selectedNode.

                    don't know if this will solve the firebug error that you were experiencing.

                    • 7. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
                      j-pro

                      Thanks, khanmurtuza, your answer really helped. Now I can work with my tree. And JScript errors has gone. Thanks again, it was very important for me.

                      But one thing I can't understand. Why this example in demo works with getTreeNode, but mine doesn't? And if I use getRowData instead of getTreeNode, I can't use such method as "isLeaf()". For sure I can use selectedNode.getNodes().length, but why there is getTreeNode() method in UITree if we should use getRowData? (it's a question for RF developers)

                      khanmurtuza, thanks again, you really helped me.

                      • 8. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip

                        You were trying to combine Tree and RecursiveTreeAdapter example, if you change the implementation of FileSystemNode.getNodes() such that it returns TreeNode instead of FileSystemNode[], I am sure it will work

                        • 9. Re: nodeSelectListener: WARN lifecycle NP Exception + JScrip
                          j-pro

                          Yeah... just messed up. Thanks again, khanmurtuza. I appreciate your help.