Dependent data container query is not being executed

Hi

I am using cascading entityComboBoxes in my screen. Let’s consider example of country and states. If I have added changeValueHandler for country combo box and statesDl query contains state.country = :component_countryField or state.country = :container_countriesDc, statesDc will not be refreshed. Removing handler from controller solves the issue.

Is this normal and expected behavior? I believe this was working in Cuba Platform.

What mode is set for the dataLoadCoordinator?

My facets entry

<facets>
    <dataLoadCoordinator auto="true"/>
    <screenSettings id="settingsFacet" auto="true"/>
</facets>

It works fine on removing countryField’s onCountryFieldValueChange() event from controller.

Why do you need or state.country = :container_countriesDc in your states query?
Could you provide a test project where your issue is reproduced?

My bad, I wasn’t clear in my question. I meant neither
select e from test_State e where e.country = :container_countriesDc
nor
select e from test_State e where e.country = :component_countryField
query works. I tried and it’s working in test project, I am trying to figure out issue in my project regarding this, everything appears to be same. Another issue I observed is that changing/clearing country doesn’t clear state field’s value. PFA test project, check out Addresses screen.

  • Select a country and then a state
  • Update/clear country, state field won’t be cleared

transient-test.zip (381.3 KB)

This is correct. You should do it programmatically in the controller:

public class AddressBrowse extends MasterDetailScreen<Address> {

    @Autowired
    private EntityComboBox<State> stateField;

    @Subscribe("countryField")
    public void onCountryFieldValueChange(HasValue.ValueChangeEvent<Country> event) {
        stateField.setValue(null);
    }
}

Thanks for confirming. Do you see any issue in the code below to implement cascading dropdowns for Country and State?

    <collection id="countriesDc" class="com.test.Country">
        <fetchPlan extends="_base">
            <property name="states" fetchPlan="_base"/>
        </fetchPlan>
        <loader id="couontriesDl">
            <query>
                <![CDATA[select e from Country]]>
            </query>
        </loader>
        <collection id="statesDc" property="states"/>
    </collection>

The code is fine, but it works only if you have a collection property in the master entity, which is not always the case.

Besides, here States are loaded for all Countries at once, which is not good if you have a lot of instances (perhaps it’s fine for countries and states). With standalone child container, you load dependent entities only for a single selected master entity, so even if you have thousands of master instances, you will have only a single master and its children in memory at a time.

1 Like