p:tree reset problem

UI Components for JSF
Post Reply
kalyaniswathi
Posts: 3
Joined: 20 Oct 2011, 06:55

20 Oct 2011, 07:12

I used to use Primefaces 2.2 :D , in which when i tried to reset the tree using a method it worked fine. All i used to do :geek: , 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 :shock: . 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 :roll: ....

Can anyone lemme know if i m missing on something!! :geek:

Thanks in advance :D

kalyaniswathi
Posts: 3
Joined: 20 Oct 2011, 06:55

20 Oct 2011, 07:24

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 51 guests