5 Replies Latest reply on Jul 11, 2007 2:52 PM by evdelst

    checkBox in TreeNode

    evdelst

      Hi,
      I am not sure if it is a richfaces or Seam question, so I double posted.

      I want to put a h:selectBooleanCheckbox in a treenode.
      The problem is, it shows up, but I can never select it.

      For a datatable, I use a bean with a Map<MyDataObject,Boolean> and a setSelection(MyDataObject) method in the (stafefull) bean. This works nicely, giving me a Map of selected objects.

      In the tree, my template looks like this:

      <rich:tree value="#{testMaintenance.testTree}" var="data" nodeFace="#{data.class.simpleName}" id="tree" switchType="client">
       <rich:treeNode id="tn" type="Test"><h:commandLink value="#{data.id}" action="#{testMaintenance.selectTest(data)}"/>
       </div> <h:selectBooleanCheckbox value="#{testMaintenance.selection[data]}"/> #{data.person.lastName} #{data.organisation.name}
       </rich:treeNode>
      


      In my bean:
      public Map<Test, Boolean> getSelection() { return this.selection; }
      
      public void setSelection(Test t) {
       logger.info("check "+t.getId());
       selection.put(t,true);
      }
      


      If I put a h:inputText in the treenode, I can type into that field.
      This pattern works for DataTable. Has anyone tried this with a rich:Tree?





        • 1. Re: checkBox in TreeNode
          danielnp

          Can you post your Test.java?

          • 2. Re: checkBox in TreeNode
            evdelst

            'Test' is a domain object.
            It looks like this (some properties removed to reduce the amount of code)

            @Entity
            @Table(name = "tes")
            public class Test {
             @Id
             @GeneratedValue(generator="nassequence")
             private Integer id;
            
             public Integer getId() {
             return id;
             }
            
             public void setId(Integer id) {
             this.id = id;
             }
            
            
            
             // more properties here....
            
             @Override
             public boolean equals(Object obj) {
             if (obj==null || !(obj instanceof Test)) {
             return false;
             }
             return this.id.equals(((Test)obj).id);
             }
            
            
             @Override
             public int hashCode() {
             return id;
             }
             }




            • 3. Re: checkBox in TreeNode
              evdelst

              Created a JIRA issue with a fix/hack.

              http://jira.jboss.com/jira/browse/RF-407

              • 4. Re: checkBox in TreeNode

                Any chance of a workaround for 3.0.1 without hacking stuff? This bug wasn't in 3.0.0, but other bugs were, so I don't want to downgrade ...

                • 5. Re: checkBox in TreeNode
                  evdelst

                  I upgraded to 3.1.0 (manual build).
                  Works fine there, but you have to change your code (TreeNode is moved to another package).
                  So it's not a drop-in replacement (also, jar is split up, so you have to modify your build also).