1
votes

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}"/>                                                                  
    <h:selectBooleanCheckbox  id="treeCheck" />        
    </p:treeNode>
</p:tree>

Any suggestions on how to pre-select the values on the tree from the backing bean.

1

1 Answers

1
votes

Something like ;

for (Iterator<TreeNode> it = root.getChildren().iterator(); it.hasNext();) {
        String name = it.next().toString();
        if (list.contains(name)) {
            it.next().setSelected(true);
        } 

    }