Created
June 1, 2012 05:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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