0 Replies Latest reply on Jun 1, 2009 3:59 AM by David Bolsover

    nodeSelectListener not fired, root node does not display

    David Bolsover Newbie

      I'm having a problem with a tree where a nodeSelectListener registered on the treeNode is not being fired; I'm reasonably sure I must be overlooking something obvious...

      Additionally, I have had to add an additional (dummy parent) treeNode since the root node does not display.

      The tree displays just fine and nodes expand colapse as required.

      Page code:

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

      Bean Code:
       /** Creates a new instance of BillExplosionBean */
       public BillExplosionBean() {
      // set-up root node and call recursive method
       public void retrieveBill(String parent){
       rootNode = new TreeNodeImpl();
       Bill bill = new Bill();
       // dummy parentNode since rootNode does not display
       TreeNode parentNode = new TreeNodeImpl();
       rootNode.addChild(bill, parentNode);
       List<Bill> bills = dao.retrieveBillByParent(parent);
       walkTree(parentNode, bills);
       FacesContext fc = FacesContext.getCurrentInstance();
       ExternalContext ec = fc.getExternalContext();
       HttpSession httpSes = (HttpSession) ec.getSession(false);
       httpSes.setAttribute(AppConstants.BILL_EXPLOSION_BEAN, this);
      // recursive method to construct the tree
       private void walkTree(TreeNode parent, List<Bill> bills){
       for (Bill bill : bills){
       // do some processing to build the tree
       TreeNodeImpl nodeImpl = new TreeNodeImpl();
       parent.addChild(bill, nodeImpl);
       // get the subordinate parts
       List<Bill> childBills = dao.retrieveBillByParent(bill.getPart());
       walkTree(nodeImpl, childBills);
      // node selection event
       public void processSelection(NodeSelectedEvent event) {
       HtmlTree tree = (HtmlTree) event.getComponent();
       nodeTitle = (String) tree.getRowData();
       TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
       if (currentNode.isLeaf()){
       Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
       while (it!=null &&it.hasNext()) {
       Map.Entry<Object, TreeNode> entry = it.next();

      Any help correcting these problems would be appreciated.