final TextInputCell fosterDateStartCell = new TextInputCell();
final Column<IFosterHistoryProxy, String> fosterDateStartColumn;
fosterDateStartColumn = new Column<IFosterHistoryProxy, String>(fosterDateStartCell) {
@Override
public String getValue(final IFosterHistoryProxy fosterHistory) {
final String date = fosterHistory.getFosterDateStart();
if (GLGWTUtil.isEmpty(date)) {
return "";
}
return date.substring(4, 6) + "/" + date.substring(6, 8) + "/" + date.substring(0, 4);
}
};
fosterDateStartColumn.setFieldUpdater(new FieldUpdater<IFosterHistoryProxy, String>() {
@Override
public void update(final int index, final IFosterHistoryProxy fosterHistory, final String value) {
final String[] dateParts = value.split("/");
if (dateParts.length != 3) {
return;
}
final int month = Integer.valueOf(dateParts[0]);
final int day = Integer.valueOf(dateParts[1]);
final int year = Integer.valueOf(dateParts[2]);
final String date = (year < 100 ? 2000 + year : year) + (month < 10 ? "0" : "") + month +
(day < 10 ? "0" : "") + day;
getEditDTO(fosterHistory, ECacheUpdateType.Update).setFosterDateStart(date);
final ViewData viewData = new ViewData(date.substring(4, 6) + "/" + date.substring(6, 8) +
"/" + date.substring(0, 4));
fosterDateStartCell.setViewData(fosterHistory.getFosterHistoryId(), viewData);
fosterHistoryGrid.redraw();
}
});
fosterDateStartColumn.setSortable(true);
fosterHistoryGrid.addColumn(fosterDateStartColumn, "Start Date");
fosterHistoryGrid.setColumnWidth(fosterDateStartColumn, "10ex");
The getValue() method is working well ... if the value in the proxy object is "20120506" then I see "05/06/2012" in the cell. But the update() method is not showing the correct value ... if the user enters "5/6/12" then I do not see "05/06/2012" (the value in the cell is still "5/6/12" after the update() method has executed). Note that the setFosterDateStart() method does not cause the update to be sent to the server; it simply sets the value in the editable proxy object. Also note that the getFosterHistoryId() method returns the stable identifier value for the IFosterHistoryProxy object, and that the key provider for the selection model associated with the DataGrid is using that identifier.
Many thanks for any help!
Andy
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment