Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem using tomahawks selectmanycheckbox-component and spreadlayout

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
This tiny ad is guaranteed to be gluten free.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic