0 Replies Latest reply on May 24, 2011 1:23 PM by locons

    rich:tree with selectbooleancheckbox

    locons

      Hi, I'm developing a web app and I want a tree where I can put a checkbox for every node (childnodes only actually), this I have been able to achive (kind of) but now I need to save those checked nodes to a DB but I don't know how to set this to my backing bean.

       

      Can anyone help me please??

       

      Here is my tree:

       

      <rich:tree id="tree" ajaxSubmitSelection="true" switchType="client" value="#{backingBean.rootNode}" var="node">

       

          <rich:treeNode>

       

                <h:outputText value="#{node}"/>

       

                <h:selectBooleanCheckbox value="#{backingBean.checked[node]}"/>

       

          </rich:treeNode>

       

      </rich:tree>

       

      The checked property is a map to join the options with a boolean for the selectbooleancheckbox

       

      this is what I have in my bean:

       

          public class BackingBean{

       

                private TreeNode<String> rootNode = new TreeNodeImpl<String>();

       

                private Map<Integer, Boolean> checked = new HashMap<Integer, Boolean>();

       

                TreeNodeImpl<String> childNode[] = new TreeNodeImpl[opciones.size()];

       

              

       

                for (int i = 0; i < options.size(); i++){

       

                      optionsMenu[i] = options.get(i);

       

                      childNode[i] = new TreeNodeImpl<String>();

       

                      childNode[i].setData(optionsMenu[i].getNombre());

       

                      childNode[i].setParent(rootNode);

       

                      rootNode.addChild("0"+i, childNode[i]);

       

                                    

       

                      List<OptionMenu> op = optionMenuService.findOptionsTree(i+1);

       

                      if(op.size()!=0){

       

                          OptionMenu[] optionsMenu1 = new OptionMenu[op.size()];

       

                          TreeNodeImpl<String> childNode1[] = new TreeNodeImpl[op.size()];

       

                          for(int a=0;a < op.size();a++){

       

                              optionsMenu1[a] = op.get(a);

       

                              childNode1[a] = new TreeNodeImpl<String>();

       

                              childNode1[a].setData(optionsMenu1[a].getName());

       

                              childNode1[a].setParent(childNode[i]);

       

                              childNode[i].addChild("0"+a, childNode1[a]);

       

                          }

       

                      }

       

                    

       

                  }

       

      Any help will be apreciated

       

      thanks in advance