<rich:tree> NullPointerException on row click
somefatman Jun 1, 2011 9:37 AMI have a <rich:tree> im using for navigation. When I click on a row I get a NullPointerException:
SEVERE: java.lang.NullPointerException javax.faces.FacesException: java.lang.NullPointerException at org.richfaces.component.UIDataAdaptor.invokeOnComponent(UIDataAdaptor.java:1124) at org.richfaces.renderkit.TreeRendererBase.decode(TreeRendererBase.java:208) at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787) at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:824) at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:55) at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337) at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1235) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) at javax.faces.component.UIForm.visitTree(UIForm.java:344) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:249) at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:229) at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:208) at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931) at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.NullPointerException at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:49) at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:35) at org.richfaces.model.NodesTreeSequenceKeyModel.setupKey(NodesTreeSequenceKeyModel.java:47) at org.richfaces.model.TreeSequenceKeyModel.setRowKey(TreeSequenceKeyModel.java:49) at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:277) at org.richfaces.component.UIDataAdaptor.invokeOnComponent(UIDataAdaptor.java:1111) ... 43 more
I have no clue what is causing this error
Here is my code:
xhtml:
<h:form id="richSideBarForm" >
<r:tree id="richTreeBar" value="#{richTree.rootNode}" var="node" toggleType="client" selectionType="ajax"
iconExpanded="/resources/images/FolderOpen_web.png" iconCollapsed="/resources/images/FolderClosed_web.png"
iconLeaf="/resources/images/Worksheet_web_mini.png" selectionChangeListener="#{richTree.processTreeSelectionChange}">
<r:treeNode id="rootNode" >
<h:outputText id="rootNodeOutput" value="#{node}" />
</r:treeNode>
<r:treeNode id="leafNode" >
<h:outputText id="leafNodeOutput" value="#{node}" />
</r:treeNode>
</r:tree>
</h:form>
BackingBean:
public class RichTree implements Serializable, TreeSelectionChangeListener{
private TreeNode rootNode;
private UITree treeBinding;
public RichTree() {
rootNode = new TreeNodeImpl();
loadTree();
}
/**
* @return the rootNode
*/
public TreeNode getRootNode() {
return rootNode;
}
public void setRootNode(TreeNode rootNode) {
this.rootNode = rootNode;
}
private void loadTree() {
AGOTreeNode summaryNode = new AGOTreeNode();
summaryNode.setLabel("0000000001");
getRootNode().addChild(0, summaryNode);
AGOTreeNode childNode = new AGOTreeNode();
childNode.setLabel("Node1");
summaryNode.addChild(0, childNode);
childNode = new AGOTreeNode();
childNode.setLabel("node2");
summaryNode.addChild(1, childNode);
}
@Override
public void processTreeSelectionChange(TreeSelectionChangeEvent tsce) throws AbortProcessingException {
List<Object> selection = new ArrayList<Object>(tsce.getNewSelection());
Object currentSelectionKey = selection.get(0);
UITree tree = (UITree) tsce.getSource();
tree.setRowKey(currentSelectionKey);
AGOTreeNode node = (AGOTreeNode) tree.getRowData();
String label= node.getLabel();
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, "", label);
}
AGOTreeNode extends TreeNodeImpl and adds a few feilds and also overwrites the toString method.
Any Help is greatly appreciated!
---EDIT---
I dont know if it is important but the navigation tree is part of one xhtml file which is being included in my template using a <ui:include> tag
-Doug Costa