I'm new to wicket and I don't know jQuery at all. I use wicket 6.9.0. I need to add select/deselect all checkbox to wicket DataTable. I've read and implemented example from "Apache Wicket Cookbook", you can see it on page 28 here Apache Wicket Cookbook. Chapter 5 but deselect all does not work. I've read also suggestion here: http://evanchooly.com/logs/%23%23wicket/2011-08-31
The problem is - I have no idea how to implement it via Check*Selector or somehow. Could anyone please help my with simple useful example?
** Update:**
As @svenmeier wrote in comment. I'm trying to add the checkgroupselector to select all the checkboxes and I did the following:
Form form = new Form("form");
CheckGroup group = new CheckGroup("group");
group.add(new CheckGroupSelector("groupselector"));
DataTable sourceTable = new DataTable("mytable", getColumns(), getDataProvider(), 10);
sourceTable.setOutputMarkupPlaceholderTag(true);
group.add(sourceTable);
add(form);
form.add(group);
private List getColumns() {
List<IColumn<MyItem, String>> ret = Lists.newArrayList();
ret.add(new AbstractColumn<MyItem, String>(new Model<>("")) {
@Override
public void populateItem(Item<ICellPopulator<MyItem>> cellItem, String componentId, IModel<MyItem> rowModel) {
CheckBoxPanel checkBoxPanel = new CheckBoxPanel(componentId);
cellItem.add(checkBoxPanel);
}
});
...
}
<span wicket:id="group">
<input type="checkbox" wicket:id="groupselector">check/uncheck all</input>
<table wicket:id="mytable">[Lookup Results]</table>
</span>
To add CheckBox to the DataTable I must use a Panel, so I have the following:
public class CheckBoxPanel extends Panel {
private CheckBox field;
public CheckBoxPanel(String id, IModel<Boolean> model) {
super(id);
field = new CheckBox("checkBox", model);
add(field);
}
public CheckBoxPanel(String id) {
this(id, new Model<Boolean>());
}
public CheckBox getField() {
return field;
}
}
In CheckBoxPanel.html
<body>
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<input type="checkbox" wicket:id="checkBox">
</wicket:panel>
</body>
Actually it does show checkgroup but under my table and checking/un-checking it does not affect the check boxes under it. What am I doing wrong here?