avoid nodes of p:treeTable to collapse after updat

2019-04-08 02:05发布

i have a p:treeTable in a form and a p:dialog in another form where from p:dialog i add data to the p:treeTable

on submit of h:commandButton of the dialog i add update of p:treeTable in orded to see the added node

The issue is that all expanded nodes the user has opened will all collapse

I found this question Avoiding the collapsing of p:treeTable after update which in the question he wrote solved but no answer or solution for his question

3条回答
贼婆χ
2楼-- · 2019-04-08 02:23

According to PrimeFaces Tree Events Showcase you forgot to use the update statement.

查看更多
虎瘦雄心在
3楼-- · 2019-04-08 02:27

To avoid collapsing or expanding you have to mark your node on the java side as collapsed or expanded. To do that that just add some ajax calls and some listener methods.

JSF/Faces:

<p:tree ...>
    <p:ajax event="expand" listener="#{backing.nodeExpand}" />
    <p:ajax event="collapse" listener="#{backing.nodeCollapse}" />
...
</p:tree>

Java/Backing:

public void nodeExpand(NodeExpandEvent event) {
    event.getTreeNode().setExpanded(true);      
}

public void nodeCollapse(NodeCollapseEvent event) {
    event.getTreeNode().setExpanded(false);     
}
查看更多
我想做一个坏孩纸
4楼-- · 2019-04-08 02:29

If you try call any action or actionListener inside the tree you need expend all node and parents, with you don't do you this only don't work and don't show any error.

node.setExpanded(true);
node.getParent().setExpanded(true);
查看更多
登录 后发表回答