Dropdown dependant on more than 1 datasources

I’ve 3 dropdowns: (A) productsDs, (B) combinationsDs, © componentsDs.

-(B) depends on (A) and could be empty. So, © should show components list from (A).
-But if (B) isn’t empty, then © should show components list from (B).
-All components, products ones and combinations one, are on the same table with a Composition relation to both tables (A) and (B).

componentsDs Query is: “select e from myapp$ComponentsTable e where (e.combination.id=:ds$combinationsDs and :ds$combinationsDs is not null) or (e.products.id=:ds$productsDs and :ds$combinationsDs is null)

An exception is thrown: “UnsupportedOperationException: Datasource couldn’t depend from two different sources

I thought about 2 lookupfields with his own datasorce each one, and make visible or not, one or other. But i’m looking for a more elegant solution.

Any sugestion? Thanks in advance

Got a solution.

I created 2 collectiondatasource

Then, at init() - propertychangelistener(), injecting both CollectionDatasources and LookupPickerField, I just change OptionsDatasource (componentsLookup.setOptionsDatasource()). It works.

1 Like