Custom property filter component inject failed

Hi team,

When define a custom property filter value component as below:

  <filter id="filter"
          dataLoader="ordersDl">
      <properties include=".*"/>
      <configurations>
          <configuration id="typeCodeConf"
                         default="true"
                         name="PropertyFilter">
              <propertyFilter property="typeCode"
                              operation="EQUAL"
                              operationEditable="true">
                  <!-- here -->
                  <comboBox id="typeCodeFilter"/>
              </propertyFilter>
          </configuration>
      </configurations>
  </filter>

and inject the comboBox into controller, it will throw exception:
image

The use case is, we need to provide limited options for the field and it’s dynamic, can’t use enum options.

Hi, Bryan!

What I know for sure is that your ComboBox is not on the screen when it is created and before it is shown.

It appears on the screen only at the moment of switching the desired configuration, even if it is standard configuration.

To initialize items for ComboBox you need to use listener of ConfigurationChangeEvent

As example:

    @Subscribe("filter")
    public void onFilterConfigurationChange(final Filter.ConfigurationChangeEvent event) {
        Filter.Configuration currentConfiguration = event.getNewConfiguration();

        if ("typeCodeConf".equals(currentConfiguration.getId())) {
            LogicalFilterComponent rootFilterComponent = currentConfiguration.getRootLogicalFilterComponent();
            //or other logic to find the component
            PropertyFilter propertyFilter = (PropertyFilter) rootFilterComponent.getOwnFilterComponents().get(0);

            ComboBox yourComponent = propertyFilter.getValueComponent();
        }
    }

I hope my answer helps you.
Or it will serve as a hint for finding a solution.

Regards,
Dmitriy

Thanks Dmitriy!

I tried your suggestion, it works. But I also tried to move the same logic into onInit, it also works, does this mean that the component had already been initialized in the screen?

Yes you are right. What I meant is that it’s impossible to access since the component is not directly attached to the screen. Access is only possible through configuration.

Hi Dmitriy,

I see, thank you!