Hi all,
Basically I have some requirements that calculate two fields and store the result in another field.
Example given
In some-ui.xml
<textField id="sumUnitField" property="propertyA" dataContainer="someDc" />
<textField id="pricePerUnitField" property="propertyB" dataContainer="someDc""/>
As far as I know, we can create Event Listener for each field and subscribe it to each component
@Subscribe("sumUnitField")
protected void onSumUnitFieldValueChange(HasValue.ValueChangeEvent<Integer> event) {
if(event.getValue()!=null) {
doingFunction();
}
}
@Subscribe("pricePerUnitField")
protected void onSumUnitFieldValueChange(HasValue.ValueChangeEvent<Integer> event) {
if(event.getValue()!=null) {
doingFunction();
}
}
But problem arise when I have 30 similar fields that have same behavior (calculate two fields), so in a easy way we can create another 30 similar event listener that call same function.
So my question here is, is there any optimal way how to solve this?
Thank you!