Win a copy of Event Streams in Action 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!