2 Replies Latest reply on Jun 2, 2009 11:51 AM by bolsover

    nodeSelectListener

    bolsover

      I'm having a real problem getting a nodeSelectListener to work... it just will not respond ehere is the page code:

       <h:panelGrid columns="2" width="100%">
       <rich:tree style="width:300px" switchType="client"
       value="#{BillExplosionBean.rootNode}" var="item" ajaxKeys="#{null}">
       <rich:treeNode nodeSelectListener="#{BillExplosionBean.processSelection}"
       reRender="selectedNode" ajaxSubmitSelection="true" >
       <h:outputText value="#{item.seq}" />
       <h:outputText value=": " />
       <h:outputText value="#{item.part}" />
       <h:outputText value=": " />
       <h:outputText value="#{item.usage}" />
       </rich:treeNode>
      
       </rich:tree>
       <h:outputText escape="false" value="Selected Node: #{BillExplosionBean.nodeTitle}" id="selectedNode" />
       </h:panelGrid>
      



      Here is the bean code



       public void retrieveBill(String parent){
       rootNode = new TreeNodeImpl();
      
       Bill bill = new Bill();
       bill.setPart(parent);
       TreeNode parentNode = new TreeNodeImpl();
       parentNode.setData(bill);
       rootNode.addChild(bill, parentNode);
       List<Bill> bills = dao.retrieveBillByParent(parent);
       walkTree(parentNode, bills);
      
       FacesContext fc = FacesContext.getCurrentInstance();
       ExternalContext ec = fc.getExternalContext();
      
       HttpServletRequest httpReq = (HttpServletRequest) ec.getRequest();
      
       httpReq.setAttribute(AppConstants.BILL_EXPLOSION_BEAN, this);
      
       }
      
      
       private void walkTree(TreeNode parent, List<Bill> bills){
       for (Bill bill : bills){
       // do some processing to build the tree
       TreeNodeImpl nodeImpl = new TreeNodeImpl();
       nodeImpl.setData(bill);
       parent.addChild(bill, nodeImpl);
       // uncomment to output to System.out
       // get the subordinate parts
       List<Bill> childBills = dao.retrieveBillByParent(bill.getPart());
       walkTree(nodeImpl, childBills);
       }
       }
      
       public void processSelection(NodeSelectedEvent event) {
       HtmlTree tree = (HtmlTree) event.getComponent();
       nodeTitle = (String) tree.getRowData();
       selectedNodeChildren.clear();
       TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
       if (currentNode.isLeaf()){
       selectedNodeChildren.add((String)currentNode.getData());
       }else
       {
       Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
       while (it!=null &&it.hasNext()) {
       Map.Entry<Object, TreeNode> entry = it.next();
       selectedNodeChildren.add(entry.getValue().getData().toString());
       }
       }
       }
      


      The tree displays nicely on the page and will expand/collapse but selecting a node does not call the processSelection(NodeSelectedEvent event) method and I am at a loss as to why.


      Anyone?

        • 1. Re: nodeSelectListener
          ilya_shaikovsky

          Let check the lifecycle execution. add please http://www.jsftutorials.net/faces-config/phaseTracker.html and check for its log.

          • 2. Re: nodeSelectListener
            bolsover

            Hi Ilya

            This is the output from the PhaseTracker log whe I select a treeNode:

            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE RESTORE_VIEW 1
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER RESTORE_VIEW 1
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE APPLY_REQUEST_VALUES 2
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER APPLY_REQUEST_VALUES 2
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE PROCESS_VALIDATIONS 3
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER PROCESS_VALIDATIONS 3
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE UPDATE_MODEL_VALUES 4
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER UPDATE_MODEL_VALUES 4
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE INVOKE_APPLICATION 5
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER INVOKE_APPLICATION 5
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker beforePhase
            INFO: BEFORE RENDER_RESPONSE 6
            02-Jun-2009 16:47:04 org.exadel.jsf.PhaseTracker afterPhase
            INFO: AFTER RENDER_RESPONSE 6
            


            Hope this helps..
            David