Domain オブジェクトへの変更をプッシュ バックするために、FieldUpdater を作成します。次に、ボタンの onClick コールバックで、リストを最初の行の値で更新します。
たとえば、値の型として MyDTO クラス (任意のドメイン オブジェクト) を取る任意の TextInputColumn の場合、次の FieldUpdater を定義できます。
myColumn.setFieldUpdater(new FieldUpdater() {
@Override
public void update(int index, MyDTO object, String value) {
// Push the changes into the MyDTO. At this point, you could send an
// asynchronous request to the server to update the database.
object.someField = value;
// Redraw the table with the new data.
table.redraw();
}
});
このような FieldUpdater を 5 つの列すべてに設定する必要があります。(someField は、更新する DTO のフィールドです)。
ボタンの onClick() コールバックで、実際のリストを更新する必要があります。次のようになります。
update_column_cell.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//Supose listDataProvider is the instance of your DataSource for your CellTable
List<MyDTO> list = listDataProvider.getList();
// get cell values for the first row (this is for one cell)
newSomeField = list.get(0).someField;
newSomeField2 = list.get(0).someField2;
for (int i = 1;i<list.size();i++) {
MyDTO dto = list.get(i);
if (newSomeField != null && newSomeField.isNotEmpty()) {
dto.someField = newSomeField;
}
if (newSomeField2 != null && newSomeField2.isNotEmpty()) {
dto.someField2 = newSomeField2;
}
}
}
})
この例では、DTO の 2 つのフィールドのみを処理します。おそらく、CellTable の列として表示している 5 つのフィールドすべてをカバーするように拡張する必要があります。