Here some thoughts about execChangedValue() trigger, depending on the situation:
Import FormData:
By default importFormData() does not trigger an execChangedValue() event when the values are imported.
The framework provides a possibility to activate the triggers with the method:
importFormData(AbstractFormData source, boolean valueChangeTriggersEnabled)
This allows you to trigger the execChangedValue() events:
importFormData(formData, true)
Reset Value:
Reset value calls execChangedValue() if the current value differs from the initial value (the initial value is determined by Scout with the value that is set during the execLoad of the FormHandler).
A possibility to avoid the execChangedValue trigger during doReset() is to add this snippet in all the value fields:
@Override
public void resetValue() {
try {
setValueChangeTriggerEnabled(false);
super.resetValue();
}
finally {
setValueChangeTriggerEnabled(true);
}
}
Set value without execChangedValue trigger:
Similar to the previous pattern, it is possible to write a utility to set a value on a field without triggering execChangedValue():
public static <T> void setValueWithoutChangedValueTrigger(IValueField<T> field, T v) {
try {
field.setValueChangeTriggerEnabled(false);
field.setValue(v);
}
finally {
field.setValueChangeTriggerEnabled(true);
}
}
Or you add this in all your value fields:
public void setValueWithoutValueChangeTrigger(String value) {
try {
setValueChangeTriggerEnabled(false);
setValue(value);
} finally {
setValueChangeTriggerEnabled(true);
}
}
---
In my opinion support to trigger of execChangedValue() or not should be improved in the Scout API directly.
What do you think?