When a node is expanded, its grandChildren (if any) are inserted in the tree,
on collapse, they are removed again. This is working, but the node below (not child) still has
the same rowNumber as before, meaning the first child of the node and the node below have
the same rowNumber, on selecting they react as the same node.
When refreshing the page (or the tree), everything is right
(I tried to adding addPartialUpdateTarget("navigationMenu");, this is not invoked).
collapseNode works OK
xhtml:
Code: Select all
<p:tree value="#{navigationBean.tree}" var="treeNode"
update="growl contentPanel" cache="false"
selectionMode="single" selection="#{navigationBean.selectedNode}"
nodeSelectListener="#{navigationBean.selectNode}"
nodeExpandListener="#{navigationBean.expandNode}"
nodeCollapseListener="#{navigationBean.collapseNode}"
dynamic="true" id="navigationMenu" style="overflow: auto;"
>
...
Code: Select all
public void expandNode(NodeExpandEvent event){
BaseTreeNode node = (BaseTreeNode)event.getTreeNode();
if(node.getChildCount() > 0){
for (TreeNode tnode : node.getChildren()){
DossierTreeNode dnode = (DossierTreeNode)tnode;
Dossier dos = (Dossier)dnode.getData();
if (!dos.getProblemen().isEmpty()){
for (Probleem pro : probleemDAOBeanImpl.getProblemen(dos)){
new ProbleemTreeNode(pro, dnode);
}
}
}
}
// RequestContext rc = RequestContext.getCurrentInstance();
// rc.addPartialUpdateTarget("navigationMenu");
}
public void collapseNode(NodeCollapseEvent event){
if(event.getTreeNode().getChildren().size() > 0){
for(TreeNode node : event.getTreeNode().getChildren()){
BaseTreeNode bnode = (BaseTreeNode)node;
bnode.setChildren(new ArrayList<TreeNode>());
}
}
RequestContext rc = RequestContext.getCurrentInstance();
rc.addPartialUpdateTarget("navigationMenu");
}