1 Reply Latest reply on Oct 26, 2008 7:13 PM by Nick Belaevski

    treeNode rendering on delete causes NPE

    Ravi Sathish Newbie

      Environment: Tomcat 6.0.x; SEAM 2.0.2.SP1; RichFaces 3.2.2

      Task:
      Simple richFaces Tree tree.xhtml:

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


      Unfortunately, I need to remove a node from the data:
      TreeNode treeNode = srbLocationNode.getParent();
       TreeNode rootNode = srbWebClient.getSrbWebDomainNode();
       if(treeNode != null && rootNode != null)
       {
       System.out.println("removing srbLocationNode from parent :"+rootNode.hashCode()+ " : "+treeNode.hashCode());
       treeNode.removeChild(srbLocationNode);
       srbLocationNode.setParent(null);
       }
      


      My MainTreeBean.java processSelection:
       public void processSelection(NodeSelectedEvent event)
       {
       HtmlTree tree = (HtmlTree)event.getComponent();
       if(tree != null)
       {
       nodeTitle = SrbWebCommonUtility.getSrbTreeNodeName(tree.getRowData());
      
       String nodeName = "";
       TreeNode currentNode = tree.getTreeNode(tree.getRowKey());
       if(currentNode != null)
       {
       if (currentNode.isLeaf())
       {
      ...
      


      I get the following NPE:
      java.lang.NullPointerException
      org.richfaces.model.TreeDataModelNodeAdaptor$1.getChild(TreeDataModelNodeAdaptor.java:68)
      org.richfaces.model.TreeDataModelNodeAdaptor$1.getChild(TreeDataModelNodeAdaptor.java:94)
      org.richfaces.model.TreeDataModel.locateTreeNode(TreeDataModel.java:226)
      org.richfaces.model.TreeDataModel.locateTreeNode(TreeDataModel.java:187)
      


      Any Help will be dearly appreciated

      Also looks like somebody already posted this kind of query https://jira.jboss.org/jira/browse/RF-3802
      But no luck there either.