Field Component Value Change Handler

Hello to everyone

Why in jmix version 2.1 FieldComponentValueChange handler is triggered when you want to edit some entity?.
got this:
@Subscribe("descripcionField")
public void onDescripcionFieldComponentValueChange(final AbstractField.ComponentValueChangeEvent<TypedTextField<String>, String> event)
{
dialogs.createMessageDialog()
.withText("Handler is triggered on edit")
.open();
}
no other code line in the DetailView.java

Normally this should be triggered when I change the value in the “descripcion” field… and it does!!
But “Edit” triggers too this function.
image
Seems like the DetailView open with no value on their fields and after init it put the values.

Thank you in advance for your time.

Hi Mihai

This is the correct behavior: the component sends the event when its value changes from empty to something.

If you don’t want to receive this event on view opening, subscribe to the ItemPropertyChangeEvent of the data container, for example:

@Subscribe(id = "stepDc", target = Target.DATA_CONTAINER)
public void onStepDcItemPropertyChange(final InstanceContainer.ItemPropertyChangeEvent<Step> event) {
    // happens only when the view is already opened
}

Regards,
Konstantin

Hello Konstantin

This makes sense to me too.

Thank you
Kind Regards