I used to use Primefaces 2.2 , in which when i tried to reset the tree using a method it worked fine. All i used to do , was to first deselect the node and then set expanded to false and then deselect the parent node. It worked fine and the code snippet is as below-
## xhtml
<p:tree value="#{roleManagerBean.root}" var="node" id="checkboxTree"
selectionMode="checkbox" propagateSelectionUp="true"
propagateSelectionDown="true"
selection="#{roleManagerBean.selectedNodes}"
nodeSelectListener="#{roleManagerBean.onNodeSelect}">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
<p:treeNode type="0">
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
<p:commandButton value="Reset" type="reset" onclick="return doclear();"/>
<p:commandButton id="hiddenbtn" value="test" actionListener="#{roleManagerBean.reset}" update="roleName,checkboxTree" immediate="true"
onclick="javascript:doclear1();" style="display: none;" />
<script language="JavaScript">
function doclear() {
document.getElementById("roleManagerForm:hiddenbtn").click();
}
function doclear1() {
document.getElementById("roleManagerForm").reset();
document.getElementById("roleManagerForm:roleManagerPanel:grid").reset();
document.getElementById("roleManagerForm:roleManagerPanel:grid:roleName").reset();
}
</script>
and in my backing bean-
public void reset(ActionEvent event)
{
for (TreeNode node : selectedNodes) {
node.setSelected(false);
node.setExpanded(false);
node.getParent().setSelected(false);
}
}
All went well till i used Primefaces2.2, but wen i switched to Primefaces 3 M2 things started to turn out a lil weird . The tree values selected are reset successfully but the nodes are not collapsed
this is the xhtml code snippet tat i m currently using,
<p:tree value="#{roleManagerBean.root}" var="node" id="checkboxTree"
selectionMode="checkbox" propagateSelectionUp="true"
propagateSelectionDown="true"
selection="#{roleManagerBean.selectedNodes}">
<p:ajax event="select" listener="#{roleManagerBean.onNodeSelect}" />
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
<p:treeNode type="0">
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
and the rest is the same ....
Can anyone lemme know if i m missing on something!!
Thanks in advance
p:tree reset problem
-
- Posts: 3
- Joined: 20 Oct 2011, 06:55
Not that i m trying to be a lil annoying, but people can someone reply soon, othrwise a bug wil be raised against my name
-
- Information
-
Who is online
Users browsing this forum: No registered users and 51 guests