Unsupported value change listener for LookupPickerField

Hi,

I’ve created a LookupPickerField listener with CUBA Studio.

At runtime, screen init throws an UnsupportedOperationException. I find in WebLookupPickerField.java:
@Override
public Subscription addFieldValueChangeListener(Consumer<FieldValueChangeEvent> listener) {
throw new UnsupportedOperationException();
}

Please tell me how does I subscribe to value change event in this case ?

Hi,

FieldValueChangeEvent is applicable for the PickerField component. As JavaDoc says this event is fired when a user inputs value manually, i.e. field editing is enabled via setFieldEditable(boolean). This event provides text (String) that can be used to generate a new PickerField value, e.g. by creating a new entity using entered text as a value for the entity attribute.

The LookupPickerField component inherits from both LookupField and PickerField, so it has the setNewOptionHandler method for the similar use case and addFieldValueChangeListener is intentionally throws an exception.

There is an event that is provided by every Field component: ValueChangeEvent.

Regards,
Gleb

Thank you for your response. :slight_smile: