The solution of user905374 did actually work. I mentioned in my first post that I already tried the solution with a selectionModel
and that it did not work. This was partially true. It does work, but only if the table does NOT contain a CheckboxCell
.
Following a working and the not working example. I think this might be a bug, but I am not sure if I miss something.
final CellTable<LicenceDto> licenseTable = new CellTable<LicenceDto>();
final SingleSelectionModel<LicenceDto> selectionModel = new SingleSelectionModel<LicenceDto>();
licenseTable.setSelectionModel(selectionModel);
//--- If I add this column, the selection does work.
Column<LicenceDto, String> workingColumn = new Column<LicenceDto, String>(new TextCell()) {
@Override
public String getValue(LicenceDto object) {
return "Works";
}
};
workingColumn.setFieldUpdater(new FieldUpdater<LicenceDto, String>() {
@Override
public void update(int index, LicenceDto object, String value) {
;
}
});
licenseTable.addColumn(workingColumn);
//--- If I add this column, the selection does NOT work anymore.
Column<LicenceDto, Boolean> notWorkingColumn = new Column<LicenceDto, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(LicenceDto object) {
return object.getEnabled();
}
};
notWorkingColumn.setFieldUpdater(new FieldUpdater<LicenceDto, Boolean>() {
@Override
public void update(int index, LicenceDto object, Boolean value) {
presenter.enableLicense(object, value);
}
});
licenseTable.addColumn(notWorkingColumn);
You can even combine multiple cells and add them to the table (e.g. LinkActionCell
etc). As long as there is no CheckboxCell
, the blue selection with the SingleSelectionModel
does work like a charm. Does anyone see what I do wrong with this CheckboxCell
or is there a bug?
UPDATE
It was simply a usage error of me. The problem was that I set handlesSelection
to true
(second parameter of the CheckboxCell
constructor) even thought I don't handle anything. Setting it to false
solves the problem.
Bottomline: Use a selection model (e.g. SingleSelectionModel
) and do not set the handlesSelection
parameter to true
of the CheckboxCell
constructor to true, if you don't handle the selection by yourself.