You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Gregor R <gr...@navitas.de> on 2008/03/07 12:01:38 UTC

Problem with and spread layout

Hi all,

I got a very frustrating issue with the tomahawk
selectmanycheckbox-component and spreadlayout.

The following code works fine:
<t:panelGrid columns="3">
  <t:panelGroup>
    <t:outputText value="Frage"/>
    <t:selectManyCheckbox id="test" layout="spread">
      <f:selectItem itemLabel="Test1" itemValue="Test1"/>
      <f:selectItem itemLabel="Test2" itemValue="Test2"/>
    </t:selectManyCheckbox>
  </t:panelGroup>
  <t:checkbox for="test" index="0"/>
  <t:checkbox for="test" index="1"/>
</t:panelGrid>

BUT, now I want to do the exact same thing, only this time dynamically in a
bean. I wrote the following lines:

            HtmlPanelGrid grid = new HtmlPanelGrid();
            grid.setColumns(3);

            HtmlPanelGroup panel = new HtmlPanelGroup();

            HtmlOutputText text = new HtmlOutputText();
            text.setValue("Frage");    
                    
            HtmlSelectManyCheckbox checkbox = new HtmlSelectManyCheckbox();
            checkbox.setId("test"); 

            SelectItem item1 = new SelectItem("Test1", "Test1");
            SelectItem item2 = new SelectItem("Test2", "Test2");
            UISelectItem foo1 = new UISelectItem();
            foo1.setValue(item1);
            UISelectItem foo2 = new UISelectItem();
            foo2.setValue(item2);

            checkbox.getChildren().add(foo1);
            checkbox.getChildren().add(foo2);
            checkbox.setLayout("spread");

            panel.getChildren().add(text);
            panel.getChildren().add(checkbox);
            grid.getChildren().add(panel); 
           
            HtmlCheckbox check1 = new HtmlCheckbox();
            check1.setFor("form:test");
            check1.setIndex(0);
            HtmlCheckbox check2 = new HtmlCheckbox();
            check2.setFor("form:test");
            check2.setIndex(1);

            grid.getChildren().add(check1);
            grid.getChildren().add(check2);
            
           
FacesContext.getCurrentInstance().getViewRoot().findComponent("form").getChildren().add(grid);

What I do get from those lines is that I have now 4 checkboxes (two directly
in the panelgroup and two in the right columns) instead of the wanted two. I
tried everything I could think of, but nothing seems to work.
By the why if I try to do this with the t:selectoneradio in combination with
t:radio everything works out fine.

Please help me
-- 
View this message in context: http://www.nabble.com/Problem-with-%3Ct%3AselectManyCheckbox%3E-and-spread-layout-tp15891146p15891146.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.