开发者

Primefaces Tree set checkboxes

开发者 https://www.devze.com 2022-12-31 17:50 出处:网络
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 fr

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);
        } 

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消