What does CheckboxColumn look like? Sven
On 07/19/2013 07:28 PM, BrianWilliams wrote:
This works just fine to add checkboxes to a ListView: final CheckGroup<Person> group = new CheckGroup<Person>("group", new ArrayList<Person>()); Form<?> form = new Form("form") { @Override protected void onSubmit() { info("selected person(s): " + group.getDefaultModelObjectAsString()); } }; add(form); form.add(group); group.add(new CheckGroupSelector("groupselector")); ListView<Person> listView = new ListView<Person>("persons", getModel()) { /** * @see * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem) */ @Override protected void populateItem(ListItem<Person> item) { item.add(new Check<Person>("checkbox", item.getModel())); item.add(new Label("name", new PropertyModel<String>(item.getDefaultModel(), "name"))); } }; listView.setReuseItems(true); group.add(listView); However, similar code to add a checkbox column to a DefaultDataTable fails. final CheckGroup<Person> group = new CheckGroup<Person>("group", new ArrayList<Person>()); Form<?> form = new Form("form2") { @Override protected void onSubmit() { info("selected person(s): " + group.getDefaultModelObjectAsString()); } }; List columns = new ArrayList(); columns.add(new CheckboxColumn("id")); columns.add(new PsPropertyColumn("Name", "name") { @Override public void populateItem(Item cellItem, String componentId, IModel rowModel) { super.populateItem(cellItem, componentId, rowModel); } }); final DataProvider dataProvider = new DataProvider(getModel()); add(form); form.add(group); group.add(new CheckGroupSelector("groupselector")); DefaultDataTable table = new DefaultDataTable("dataTable", columns, dataProvider, 5) { }; group.add(table); The checkboxes appear, but selecting on actually selects the column rather than the individual item. This causes multiple problems, such as getDefaultModelObjectAsString() returns the column and the CheckGroupSelector, thinking the column is selected and the same column is used for all checkboxes, selects all boxes on post back. Any advice? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-checkbox-column-to-DefaultDataTable-tp4660374.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org