4 Replies Latest reply on Oct 16, 2008 4:43 PM by Ravi Sathish

    richTree remove TreeNode

    Ravi Sathish Newbie

      richFaces Newbie:
      Have a simpleTree based on http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model

      Problem:
      I want to remove couple of Nodes from my Tree; Unfortunately these nodes still show up on the Tree:
      tree.xhtml

      <rich:tree style="width:300px" nodeSelectListener="#{mainTreeBean.processSelection}"
       reRender="selectedNode" ajaxSubmitSelection="true" switchType="ajax" value="#{mainTreeBean.treeNode}"
       var="item" nodeFace="#{item.type}">


      backing bean: MainTreeBean.java
      public void getMainTree() throws Throwable
       {
       initializeNodes();
      
       AuxillaryThread auxillaryUserThread = new AuxillaryThread(this,srbWebClient,SrbCommonUtility.User);
       auxillaryUserThread.start();
       auxillaryUserThread.join();
      

      processSelection:
      public void processSelection(NodeSelectedEvent event)
       {
       //HtmlTree tree = (HtmlTree) event.getComponent();
       UITree tree = (UITree)event.getComponent();
       nodeTitle = SrbWebCommonUtility.getSrbTreeNodeName(tree.getRowData());
       log.debug("nodeTitle: "+nodeTitle);
       selectedNodeChildren.clear();


      removeTreeNode code:
      TreeNode locations_At_LocationsNode = SrbWebCommonUtility.srbGetTreeNodeFromUserTree(locationNode, SrbCommonUtility.locations, SrbCommonUtility.locations);
       if(locations_At_LocationsNode != null)
       {
       TreeNode treeNode = locations_At_LocationsNode.getParent();
       if(treeNode != null)
       {
       System.out.println("removing locations@locations "+locations_At_LocationsNode.hashCode()+" from locationNode : "+treeNode.hashCode());
       treeNode.removeChild(locations_At_LocationsNode);
       }
       }


      Any idea?Please let me know what I might be doing wrong?