my dog learned polymorphism*
The moose likes JSF and the fly likes Problem using tomahawks selectmanycheckbox-component and spreadlayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem using tomahawks selectmanycheckbox-component and spreadlayout" Watch "Problem using tomahawks selectmanycheckbox-component and spreadlayout" New topic
Author

Problem using tomahawks selectmanycheckbox-component and spreadlayout

Gregor Raschke
Greenhorn

Joined: Mar 07, 2008
Posts: 1
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>
<tutputText 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem using tomahawks selectmanycheckbox-component and spreadlayout