p:tree节点select事件监听方法没有被调用

发布于 2024-12-16 18:31:23 字数 865 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的新欢旧爱 2024-12-23 18:31:23

更新测试是什么意思?

您应该发布整个 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" or update=":myFormId") or even a panel inside the form like this: update=":myFormId:myPanelId".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文