chetan
chetan

Reputation: 125

Wicket : Check of CheckGroup not getting the selected options and perform the submit action

I'm a newbie to WICKET and got stuck using PageableListView.

For selection of individual checkboxes I'm using Check and for group selection CheckGroupSelector.

Now inspite of using Check if I use CheckBox my code works fine but unable to get selectall working...... Pasting the piece of code for reference.

    final CheckGroup<DriveInfo> group = new CheckGroup<DriveInfo>("group", new ArrayList<DriveInfo>());
    driveSearchForm.add(group);
    group.add(new CheckGroupSelector("allSelected"));
    group.setOutputMarkupId(true);

    PageableListView<DashboardModel> pageableListView = new PageableListView<DashboardModel>("searchResults",
            driveDataModel, 50) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<DashboardModel> item) {
            DashboardModel model = item.getModelObject();
            item.add(new Check("selected", new PropertyModel(model, "selected")));
            item.add(new Label("name", item.getModelObject().getName()));
            item.add(new Label("status", item.getModelObject().getStatus().toString()));
            item.add(new Label("driveUrl", item.getModelObject().getDriveURL()));
        }
    };
    pageableListView.setReuseItems(true);

Now instead of

item.add(new Check("selected", new PropertyModel(model, "selected")));

If I use

item.add(new CheckBox("selected", new PropertyModel(model, "selected")));

it's working fine......but how should I get selectall(i.e. CheckGroupSelector) also working .

Upvotes: 2

Views: 2451

Answers (1)

tetsuo
tetsuo

Reputation: 10896

The model for Check must hold the object which will be inserted into the CheckGroup list, in your case, a DriveInfo instance. It seems that you are passing a boolean (selected) value, not the object to be selected.

Upvotes: 2

Related Questions