Jmix version: 2.2.1
Jmix Studio plugin version: 2.2.0-233
IntelliJ IDEA 2023.3.3 (Community Edition)
Build #IC-233.14015.106, built on January 25, 2024
Runtime version: 17.0.9+7-b1087.11 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
GC: G1 Young Generation, G1 Old Generation
Kotlin: 233.14015.106-IJ
java 17.0.4 2022-07-19 LTS
Java™ SE Runtime Environment (build 17.0.4+11-LTS-179)
Java HotSpot™ 64-Bit Server VM (build 17.0.4+11-LTS-179, mixed mode, sharing)
Operating System: macOS 14.4 (23E214)
Metal Rendering: ON
File System: Case-Sensitive Journaled HFS+ (APFS)
Browser: Safari - Version 17.4 (19618.1.15.11.12)
Database: PostgreSQL 13
Hello Jmix Team
I am in the process of migrating my application to the Flow UI and have discovered an unexpected behaviour with the setItems()
method, that I believe is incorrect.
I am replacing the Jmix 1.5.x <comboBox/>
component with the Flow UI <select/>
component and since I am cascading the selections for multiple <select/>
components, I need to call the setItems()
method depending upon previous selections.
In both CUBA and Jmix 1.x.x calling the setOptionsList()
method of a component did not change the value of the entity attribute defined in the component’s property in the XML descriptor. In Jmix 2.x.x calling the setItems()
method of a <select/>
component sets the value of the entity attribute defined in the component’s property to null. You can see this in the following images; the first two images are from Jmix 1.5.5, where the Style value is retained after calling setOptionsList()
:
With Jmix 2.2.1 Style is set to null when calling setItems()
:
Here are the two example projects used to generate the images above:
combobox.zip (95.4 KB)
select.zip (105.1 KB)
This new situation creates at least these two problems in the DetailView:
-
You cannot open the DetailView screen for editing (after the initial instance creation) and programmatically set the items without changing the value. Therefore, since the attribute is set to null without any user interaction, exiting a view using the cancel button always asks if the user wants to save their changes, even when they did not make any.
-
If you want to avoid this problem (point 1 above), you must remove the attribute from the XML component’s property, but then you must set the component’s label initially and always manually handle the setting of the value or programmatically set the ValueSource after setting the items.
e.g.
@Subscribe
public void onBeforeShow(final BeforeShowEvent event) {
styleField.setLabel(messages.getMessage("com.company.select.entity", "MusicChoice.style"));
styleField.setItems(getMusicStyleList(musicChoiceDc.getItem().getCategory()));
styleField.setValueSource(new ContainerValueSource<>(musicStyleDc, "style"));
styleField.setValue(musicChoiceDc.getItem().getStyle());
}
I used setOptionsList()
in CUBA, respectively, in Jmix 1.5.x extensively and this new behaviour in Flow will require me to rewrite many views during the migration.
Can you please consider changing/correcting this setItems()
behaviour. Thanks in advance for your support.
Best regards
Chris