Filter Parameter Where Condition With List Type Parameter

I am trying to create a custom filter with cascading values across two parameters. Both parameters should allow for multi selection (list) and the second parameter contains a param where clause filtering the available values based on the selection of the first parameter.

I have this filter working with a single selection on the second parameter but as soon as I check the “List” setting on the second parameter I am presented with the following error and stack trace when trying to select values for this parameter. It seems like the popup selection window is not being passed the param where clause properly or something.

java.lang.NullPointerException
	at com.haulmont.cuba.gui.data.impl.AbstractCollectionDatasource.getQueryParameters(AbstractCollectionDatasource.java:259)
	at com.haulmont.cuba.gui.data.impl.AbstractCollectionDatasource.createDataQuery(AbstractCollectionDatasource.java:495)
	at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.beforeLoadData(CollectionDatasourceImpl.java:635)
	at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.loadData(CollectionDatasourceImpl.java:609)
	at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.refresh(CollectionDatasourceImpl.java:161)
	at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.refresh(CollectionDatasourceImpl.java:119)
	at com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools.createOptionsDatasourceForLookup(DynamicAttributesGuiTools.java:268)
	at com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.createComponentForEntity(ListEditorPopupWindow.java:276)
	at com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.initAddComponentLayout(ListEditorPopupWindow.java:169)
	at com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.init(ListEditorPopupWindow.java:124)
	at com.haulmont.cuba.gui.WindowManager.init(WindowManager.java:1247)
	at com.haulmont.cuba.gui.WindowManager.initWrapperFrame(WindowManager.java:1236)
	at com.haulmont.cuba.gui.WindowManager.createWindow(WindowManager.java:581)
	at com.haulmont.cuba.gui.WindowManager.openWindow(WindowManager.java:750)
	at com.haulmont.cuba.web.WebWindowManager.openWindow(WebWindowManager.java:158)
	at com.haulmont.cuba.gui.components.listeditor.ListEditorDelegateImpl$1.actionPerform(ListEditorDelegateImpl.java:121)
	at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:46)

Hi, @Corey.Amoruso!

I’ve reproduced your problem and it seems like a bug, so I’ve created a GitHub issue. It doesn’t matter if first param is list or not, the problem occurs if second param marked as list. Could you please specify platform version that you use?

Regards,
Sergey

We are on Cuba 6.10.7 at the moment. Thanks.

Sergey,

We have been testing this fix and it seems to work for most cases but not all. We found that if the first parameter is not a list things work great, even if no value is selected for the first parameter.

However we found an issue if the first parameter is a list and no value is selected. It appears that nothing (not even a null value) is passed into the second parameter causing a hard error when accessing the component for the first parameter to check its’ value. I tried adding a null check to my second parameter to detect this situation and handle gracefully but an error is thrown even before I can check for a null value.

It seems that if the first parameter is not a list then a null value is passed into the second parameter and I can detect this and manually handle it. I would expect the same behavior for the list.

We are currently running on Cuba Version 7.1.3.

Thank you,
Corey Amoruso

Hi, @Corey.Amoruso!

I’ve tried to reproduce that case with Cuba v.7.1.3+ but error did not occur. As first parameter I tried entity and non-entity lists. Maybe I’m just missing something so could you please provide sample project which throwing error?

Regards,
Sergey

I’ve done some more testing and it seems the error goes away if I save my filter, close the browse screen and then come back. It only happens when the filter is first created, after that it seems to work. I am going to mark this thread resolved.