2012-10-08 30 views
2

我正在使用<p:tree>。並嘗試使用<p:ajax>來檢測選定的節點和超出操作。這是我的實際JSF代碼:如何使用<p:ajax>內部<p:tree>的primefaces?

<p:tree id="treeDot" value="#{beanRequest.rootDot}" var="node" selectionMode="single" 
    nodeSelectListener="#{beanRequest.clt}" > 
    <p:ajax event="select" listener="#{beanRequest.clientSelected}" /> 
     <p:treeNode> 
      <h:outputText value="#{node}" /> 
     </p:treeNode> 
</p:tree> 

服務器端方法:

//... 
private Client clt; 
public void clientSelected(NodeSelectEvent event) { 
    //... 
} 
//... 

我得到以下異常:

8 oct. 2012 17:30:01 com.sun.faces.context.PartialViewContextImpl processPartial 
INFO: java.lang.NullPointerException 
java.lang.NullPointerException 
    at org.primefaces.component.api.UITree.findTreeNode(UITree.java:111) 
    at org.primefaces.component.api.UITree.setRowKey(UITree.java:78) 
    at org.primefaces.component.tree.TreeRenderer.decodeSelection(TreeRenderer.java:62) 
    at org.primefaces.component.tree.TreeRenderer.decode(TreeRenderer.java:38) 
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787) 
    at org.primefaces.component.api.UITree.processDecodes(UITree.java:170) 
    at org.primefaces.component.tree.Tree.processDecodes(Tree.java:366) 
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:506 
) 
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) 
    at org.primefaces.component.api.UITree.visitTree(UITree.java:392) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at org.primefaces.component.tabview.TabView.visitTree(TabView.java:400) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 
    at javax.faces.component.UIForm.visitTree(UIForm.java:371) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) 

回答

0

我發現了錯誤。 只是 selection="#{beanRequest.selectedNode}" 更換nodeSelectListener="#{beanRequest.clt}"並使用您創建的beanRequest這樣 private TreeNode selectedNode;

+0

哪個Primefaces版本的selecttedNode變量? – Ghasfarost

+0

@Ghasfarost我正在使用3.4.2 –

相關問題