entityComboBox - How to update display/instance name after edit?

Jmix 2.3.0

I have a standard detail view that includes an entityComboBox for selecting and viewing the mailing address. When the address needs to be modified, the user clicks the magnifying glass (entity_open) button where the address entity is presented in a dialog. The address is modified and changes saved by clicking OK.

Now when we return back to the detail screen, the entityComboBox still shows the old instance name without the changes. The user wonders if the changes worked. They must save and reopen the detail view to see the new address.

Is there any way to have the component or detail view reload the address entity instance name after it is modified?

Hello!

Thank you for reporting the problem! I created a task in our GitHub repository: EntityComboBox does not update its value after editing entity via EntityLookupAction · Issue #3486 · jmix-framework/jmix · GitHub

As a workaround, you can manually update value. For instance, you can “install” handler for EntityLookupAction's afterSaveHandler:

@ViewComponent
private EntityComboBox<Address> addressField;

@Install(to = "addressField.entityOpen", subject = "afterSaveHandler")
private void addressFieldEntityOpenAfterSaveHandler(final Address address) {
    addressField.getDataProvider().refreshItem(project);
    addressField.setValue(null);
    addressField.setValue(address);
}

If you have AddressField value change listeners, you should handle fake value change event. For instance, you can manually remove registration before setting “null” value and then add listeners again.