The examples at
http://wicketstuff.org/wicket13/compref/;jsessionid=2AF2BC5B8195BE6BA0EFADE26E35292F?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.CheckGroupPage
and http://cwiki.apache.org/WICKET/listview-with-checkboxes.html provided some 
help, but don't have enough details, such as how to pre-set the Checkbox to be 
checked. The CheckGroup is not covered in Wicket books.

Could someone who has used CheckGroup verify if this is the right way to use 
CheckGroup and Check?

CheckGroup itemGroup = new CheckGroup ("group",  selection);
   // the selection is a List<Item> representing the possible choices

    form.add (itemGroup);
itemGroup.add ( new CheckGroupSelector ("groupselector",  itemGroup));
// for (un)check all

   // the listOfSelected is a List<Item> representing the items currently 
checked
    ListView itemList = new ListView("item_list", listOfSelected) {

                protected void populateItem(ListItem item) {

                  Item t = (Item)item.getModelObject();

                  item.add (new Check ("ckbox_item",
                                                                  
item.getModel(),
                                                                  itemGroup));

                  item.add (new Label("item_title", t.getName()));
                }
      };
    itemGroup.setReuseItems(true);
    itemGroup.add(itemList);


Reply via email to