Primefaces Tree set checkboxes
I have a JSF application using Primefaces. I use the multiselect tree component which includes a checkbox on each tree node. My problem is that I need to preselect the tree nodes with values coming from the backing bean. It seems that jquery will be the way to go but I don't know how to retrieve the object values from the managedbean in jquery and how to select the tree nodes.
<p:tree cache="true" id="InstrumentTree"
selection="#{managedbeans$AssignmentsManagedBean.selectedNodes}"
value="#{managedbeans$AssignmentsManagedBean.root}" var="node" widgetVar="InstrumentTree1">
<p:treeNode>
event="select"/>
<h:outputText value="#{node.name}"/> 开发者_如何学JAVA
<h:selectBooleanCheckbox id="treeCheck" />
</p:treeNode>
</p:tree>
Any suggestions on how to pre-select the values on the tree from the backing bean.
Something like ;
for (Iterator<TreeNode> it = root.getChildren().iterator(); it.hasNext();) {
String name = it.next().toString();
if (list.contains(name)) {
it.next().setSelected(true);
}
}
精彩评论