p:tree节点select事件监听方法没有被调用
我正在使用 PrimeFaces 3.0.M4。我想在树节点选择上更新 PrimeFaces 布局单元的内容。我已将以下方法添加到我的支持 bean 中:
public void setSelectedNode(TreeNode selectedNode) {
this.selectedNode = selectedNode;
this.selectedNode.setSelected(true);
}
public void onNodeSelect(NodeSelectEvent e) {
this.setSelectedNode(e.getTreeNode());
}
在视图中,我使用 ajax 触发 onNodeSelect()
侦听器方法:
<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>
注意:树位于另一个 PrimeFaces 布局单元内。
但是当我运行它时,根本不调用 onNodeSelect()
方法。这是如何引起的以及如何解决?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新测试
是什么意思?您应该发布整个 xhtml 代码!另外,您不应该尝试更新整个布局单元,而应该更新您的表单(
update="myFormId"
或update=":myFormId"
),甚至是表单内的面板像这样:update=":myFormId:myPanelId"
。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"
orupdate=":myFormId"
) or even a panel inside the form like this:update=":myFormId:myPanelId"
.