2 Replies Latest reply on Apr 1, 2010 9:56 AM by E Geylani

    tree node delete problem

    E Geylani Novice

      Hey everybody,

       

      i must remove selected node from rich:tree..

      after i select a node, i use a button to delete the object, the result seems ok, except the errorenous state of tree (you may see the atachment), is there some way to further update the view or am i missing something ?

       

      thx

       

       

      public void nodeDelete(TreeNode<NodeData> selectedTreeNode) {
                     
              NodeData nodeData = selectedTreeNode.getData();               
              NodeData parentData = nodeData.getParent();
             
              parentData.getSubSet().remove(nodeData);
              nodeData.setParent(null);
              TreeNode<NodeData> parentNode = selectedTreeNode.getParent();
             
              parentNode.removeChild(nodeData);
                     
              selectedTreeNode.setParent(null);       
          }

        • 1. Re: tree node delete problem
          Nick Belaevski Master

          Hi,

           

          You should re-render the parent node of the removed node.

          • 2. Re: tree node delete problem
            E Geylani Novice

            thx for the answer but when i reRender the treeNode getting an IllegalStateException..

             

            java.lang.IllegalStateException: No tree element available or row key not set!
                at org.richfaces.model.TreeDataModel.isLeaf(TreeDataModel.java:290)
                at org.richfaces.component.UITree.isLeaf(UITree.java:492)
                at org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:161)
                at org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:106)
                at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:101)
                at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:528)