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

    richTree remove TreeNode

    raviies

      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?

        • 1. Re: richTree remove TreeNode
          raviies

          Can it be a problem of page refresh?

          I mean is there a java swing call like tree.updateUI() in richFaces?

          Ravi

          • 2. Re: richTree remove TreeNode
            sri_hari

            did u enclose the tree withing <a4j:outputPanel ajaxRendered="true">?
            Try doing it.
            You can find out whether it is an refresh issue or not

            • 3. Re: richTree remove TreeNode
              nbelaevski

              Ravi,

              There's no such call. You should use ajaxKeys attribute to point to keys of nodes you wish to update.

              P.S. You can refresh page by F5 if the beans are session-scoped to check if changes were applied correctly.

              • 4. Re: richTree remove TreeNode
                raviies

                I'm still baffled by this problem

                I did a simple test:

                I added 5 nodes & removed the 4 node; But still all the 5 nodes show up

                rootNode.addChild(new Integer(users_order),domainNode);
                 rootNode.addChild(new Integer(locations_order),locationRootNode);
                 rootNode.addChild(new Integer(executables_order),executableRootNode);
                 rootNode.addChild(new Integer(schemes_order),rootSchemeNode);
                 rootNode.addChild(new Integer(token_order),tokenNode);
                
                 rootNode.removeChild(rootSchemeNode);


                Has somebody tried removing nodes?