If I get the value of a valueChangeListener on a PickerField it returns null if I choose the same customer the second time.
Is it a vaadin bug?
@Named("fieldGroup.customer")
PickerField customer;
@Override
public void init(Map<String, Object> params) {
super.init(params);
customer.addValueChangeListener(e -> {
if (e.getValue() != null) {
showNotification("e.value: " + e.getValue(), NotificationType.HUMANIZED);
} else {
showNotification("e.value is null", NotificationType.ERROR);
}
});
}
I've created a example-project on GitHub
For now PickerField LookupAction calls setValue() method twice (with null value and with the selected) if the new item has the same id as current to ensure that previous item will be replaced with the new. That leads to two calls of ValueChangeListener with null and then with the new value.
It is a known API issue of CUBA and we will try to change it may be in the next major release of the platform, but now you have to check for null e.getValue() and entity attribute that is bound to a PickerField.