1 Reply Latest reply on Jul 6, 2011 5:06 AM by bcn

    NullPointerException in rich:tree node selection

    bcn

      In a tree selection listener method I update the tree itself and get a nullpointerexception afterwards:

       

      18:43:37,156 SEVERE [org.richfaces.log.Context] null: java.lang.NullPointerException

          at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:49) [:4.0.0-SNAPSHOT]

          at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:35) [:4.0.0-SNAPSHOT]

          at org.richfaces.model.NodesTreeSequenceKeyModel.setupKey(NodesTreeSequenceKeyModel.java:47) [:4.0.0-SNAPSHOT]

          at org.richfaces.model.TreeSequenceKeyModel.setRowKey(TreeSequenceKeyModel.java:49) [:4.0.0-SNAPSHOT]

          at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:277) [:]

          at org.richfaces.renderkit.TreeRendererBase.encodeSelectionStateInput(TreeRendererBase.java:131) [:4.0.0-SNAPSHOT]

          at org.richfaces.renderkit.html.TreeRenderer.encodeEnd(TreeRenderer.java:145) [:4.0.0-SNAPSHOT]

          at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [:2.1.1-FCS]

          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763) [:2.1.1-FCS]

          at org.richfaces.context.ExtendedPartialViewContextImpl$RenderVisitCallback.visit(ExtendedPartialViewContextImpl.java:514) [:4.0.0-SNAPSHOT]

          at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337) [:4.0.0-SNAPSHOT]

          at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1235) [:]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [:2.1.1-FCS]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [:2.1.1-FCS]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [:2.1.1-FCS]

          at javax.faces.component.UIForm.visitTree(UIForm.java:335) [:2.1.1-FCS]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [:2.1.1-FCS]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [:2.1.1-FCS]

      ...

       

      The problem seems to occur when a node is selected which is not present in the new tree.

      But the implementation should be so robust that there is no exception.

      Is this a bug? Is it not possible to modify the tree in a tree selection listener?

       

      I do not reassign the bound root node object, instead I remove all child nodes and add the new nodes to the root.

       

      The tree definition is:

       

      <rich:tree value="#{searchBean.suggestTree}" var="node" id="treeSuggest"

      nodeClass="com.myapp.web.tree.EstabSuggestTreeNode"

      nodeType="#{node.type}" selectionType="ajax"

      toggleType="client" render="treeSuggest,detail"

      selectionChangeListener="#{searchBean.treeSuggestSelectionChanged}">

      <rich:treeNode type="neighborhood">

          <h:outputText value="#{node.name}" />

          </rich:treeNode>

          <rich:treeNode type="estab" >

          <h:outputText value="#{node.name}" />

      </rich:treeNode>

      </rich:tree>

       

      RichFaces 4.0.0.

       

      Thanks