ListBoxes / SelectionCellsをCellTableに追加する方法については、Goolgeの例に従っていますが、動作を変更する方法がわからないため、表示されている文字列値ではなく照合が行われます。
@SelectionCellに表示する項目は一意ではないため(つまり、同じ名前の要素が2つある可能性があります)、オブジェクトに関連付けられている他のフィールドを使用して、どちらが選択されたかを知る必要があります。
for (IrrigationProgramDTO program: programOptions)
categoryNames.add(program.getName());
SelectionCell categoryCell = new SelectionCell(categoryNames);
Column<IrrigationGapDTO, String> categoryColumn = new Column<IrrigationGapDTO, String> (categoryCell) {
@Override
public String getValue(IrrigationGapDTO object) {
if (object.getProgramSelected()!=null)
return object.getProgramSelected().getName();
else
return "";
}
};
categoryColumn.setFieldUpdater(new FieldUpdater<IrrigationGapDTO, String>() {
public void update(int index, IrrigationGapDTO object, String value) {
for (IrrigationProgramDTO program: programOptions) {
//not valid as there could be more than 1 program with the same name
if (program.getName().equals(value)) {
object.setProgramSelected(program);
break;
}
}
}