Skip to content

Instantly share code, notes, and snippets.

@fastnsilver
Created June 1, 2012 05:02
Show Gist options
  • Save fastnsilver/2848957 to your computer and use it in GitHub Desktop.
Save fastnsilver/2848957 to your computer and use it in GitHub Desktop.
Snippet of GWT client code attempting to "wrap" a number of ValidatableInputCell invoking onBrowserEvent for each
public class CompositeValidatableColumn<T> extends IdentityColumn<T> {
public CompositeValidatableColumn(WrapperCell<T> cell) {
super(cell);
}
@Override
public WrapperCell<T> getCell() {
return (WrapperCell<T>) super.getCell();
}
@Override
public void onBrowserEvent(Context context, Element elem, final T object, NativeEvent event) {
final int index = context.getIndex();
final WrapperCell<T> wrapper = getCell();
for (final HasCell<T, String> hasCell: wrapper.getInnerCells()) {
final FieldUpdater<T, String> f = hasCell.getFieldUpdater();
final Cell<String> innerCell = hasCell.getCell();
if (innerCell instanceof ValidatableInputCell) {
final ValidatableInputCell vic = (ValidatableInputCell) hasCell.getCell();
final ValueUpdater<String> valueUpdater = f == null ? null : new ValueUpdater<String>() {
@Override
public void update(String value) {
f.update(index, object, value);
}
};
vic.onBrowserEvent(context, elem, vic.getViewData(object).getValue(), event, valueUpdater);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment