I have a page with a <p:tree>. On click of the node, node detail is shown on the same page. When another node is selected, node detail section is refreshed with new node info. I followed show case tree - AJAX selection sample code, it works fine when the detail section is view only.
Then I changed the detail section to updateable input form, I encountered a problem.
Code: Select all
<p:tree value="#{treeBean.root}" var="node"
selectionMode="single" selection="#{treeBean.selectedNode}"
nodeSelectListener="#{treeBean.onNodeSelect}>
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
...
<h:inputText value="#{myBean.editingData.name}" />
1. Tree node A is selected, treeBean.selectedNode is set to A
2. nodeSelectListener treeBean.onNodeSelect is invoked. myBean.editingData is set to A
3. Detail section is rendered, input field value is name of A
4. Tree node B is selected. treeBean.setSelectedNode is invoked. treeBean.selectedNode set to new node B.
5. nodeSelectListener treeBean.onNodeSelect is invoked. myBean.editingData is set to B
6. Since the <h:inputText > field has value as name of A, editingData.setName(A) is invoked, but editingData is already changed to B in step 5.
Here come to the problem that node B is assigned node A's name, which is not intended.
Any idea how to avoid this problem? For example can I delay invoke of nodeSelectListener ?
Thanks.