p:tree node select event listener method is not invoked

自闭症网瘾萝莉.ら 提交于 2020-01-14 06:15:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!