In my application I am using the p:tree in selectionMode:checkbox. Code is below:
<p:tree id="tree_permissoes" value="#{mBTipoUsuario.root}" var="node" selectionMode="checkbox" selection="#{mBTipoUsuario.selectedNodes} widgetVar="treeSingleWidget"">
<p:treeNode>
<h:outputText value="#{node}"/>
</p:treeNode>
I am having some problems to get the selected nodes in "mBTipoUsuario.selectedNodes" array. When the user click in a certain button I load the p:tree with some pre-selected nodes from the managed bean. Then, the user can select some other nodes, of their choice, in the p:tree and submit back to the managed bean. The problem is, in "mBTipoUsuario.selectedNodes" array, I just get the nodes that the user explicitly checked, but a miss the nodes that were pre-selected from the managed bean.
THE QUESTION IS: How to get both, the pre-selected nodes from the managed bean and those nodes explicitly selected by the user?
I have already tried to select the nodes I want to be pre-selected in the client side, as shown here: PrimeFaces Tree component, setting selected node from managed bean
But I have not any success. Can anyone help-me? Thanks.