addObjectAdapterValidator();
}
private void addObjectAdapterValidator() {
final ScalarModel scalarModel = getModel();
final TextField<java.util.Date> textField = getTextField();
textField.add(new IValidator<java.util.Date>() {
private static final long serialVersionUID = 1L;
@Override
public void validate(final IValidatable<java.util.Date> validatable) {
final java.util.Date proposedValue = validatable.getValue();
final Date proposed = new Date(proposedValue);
final ObjectAdapter proposedAdapter = adapterFor(proposed);
final String reasonIfAny = scalarModel.validate(proposedAdapter);
if (reasonIfAny != null) {
final ValidationError error = new ValidationError();
error.setMessage(reasonIfAny);
validatable.error(error);
}