0 Replies Latest reply on Apr 15, 2008 7:14 AM by jhs2zz

    tree with checkbox, how to save checkbox values

    jhs2zz

      Hi, I posted same question in another thread, but it is pretty much dead and no response so I'd try again here and try to simplify the question.

      I have made a tree using recursiveTreeNodeAdapter and added a checkbox to each of the node. I d like when the checkbox is clicked, save the tree state and remember which checkboxes are checked, then re-render the tree using the stored state.

      I have tried

       <rich:tree id="myTree"
       style="width:300px"
       switchType="ajax"
       componentState="#{treeTest.treeState}
       stateVar="treeState">
       <rich:recursiveTreeNodesAdaptor id="myTreeNodes" roots="#{treeTest.rootChildren}" var="item"
       nodes="#{item.children}">
       <rich:treeNode id="myTreeNode">
       <h:selectBooleanCheckbox id="checkbox" value="#{item.checked}">
       <a4j:support
       event="onclick"
       reRender="myTree"
       action="#{item.processCheckBoxChanged}"
       />
       </h:selectBooleanCheckbox>
       <h:outputText value="#{item.label}"/>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
       </rich:tree>
      


      The method "processCheckBoxChanged" only sets a boolean variable.

      The above code doesnt work. Only when I remove "componentState="#{treeTest.treeState}" it works but obviously checkbox states are not saved or restored.

      Any suggestions please, what have I done wrong?

      Many thanks!