bindBeanProperty(dataBindingContext, mmng, bean, propertyName, validator, value, control);
}
public static void bindBeanProperty(DataBindingContext dataBindingContext, final IMessageManager mmng,
Object bean, final String propertyName, IValidator validator, IObservableValue value, final Control control) {
IObservableValue modelValue = BeanProperties.value(propertyName).observe(bean);
UpdateValueStrategy targetToModel = new TrimmingUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
//UpdateValueStrategy modelToTarget = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
UpdateValueStrategy modelToTarget = new TrimmingUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
if (validator != null) {
targetToModel.setBeforeSetValidator(validator);
modelToTarget.setBeforeSetValidator(validator);
}
Binding bindValue = dataBindingContext.bindValue(value, modelValue, targetToModel, modelToTarget);
final IObservableValue validationStatus = bindValue.getValidationStatus();
validationStatus.addChangeListener(new MessageChangeListener(validationStatus, control,
propertyName, mmng));
// we need to call validation here otherwise the fresh initiated fields
// would
// have no error decoration if field is invalid on init phase