问题
I am using PrimeFaces 3.0.M4. I want to update the contents of PrimeFaces layout unit on tree node selection. I have added the following methods to my backing bean:
public void setSelectedNode(TreeNode selectedNode) {
this.selectedNode = selectedNode;
this.selectedNode.setSelected(true);
}
public void onNodeSelect(NodeSelectEvent e) {
this.setSelectedNode(e.getTreeNode());
}
In the view I am using ajax to trigger the onNodeSelect()
listener method:
<p:tree id="tree" value="#{treeBean.root}" selection="#{treeBean.selectedNode}" var="node" selectionMode="single" dynamic="true" cache="false" >
<p:ajax listener="#{treeBean.onNodeSelect}" update="test" event="select"/>
<p:treeNode>
<h:outputText value="#{node}"/>
</p:treeNode>
</p:tree>
Note: the tree is inside another PrimeFaces layout unit.
But when I run this, the onNodeSelect()
method is not called at all. How is this caused and how can I solve it?
回答1:
What does it mean update test
?
You should post your entire xhtml code! Also you should not try to update the entire layoutUnit but instead update your form (update="myFormId"
or update=":myFormId"
) or even a panel inside the form like this: update=":myFormId:myPanelId"
.
来源:https://stackoverflow.com/questions/8182741/ptree-node-select-event-listener-method-is-not-invoked