Interaction between filter manualApplyRequired, filters and Loader load() call

Hello all:

Here’s an interesting wrinkle I just discovered. The filter manualApplyRequired option is used to ensure that the user presses “Search” so that the filter does not execute when a screen is first loaded.

This works great, but in my case it interfered with my own use of the loader. I have an extra filter that I wrote based on a dropdown selection in addition to the normal filter. When I set manualApplyRequired= “true”, my own loader stopped loading anything.

After stepping through all the code, I discovered that manualApplyRequired = “true” was implemented by adding an extra jpql condition to the loader query of “where 0<>0”. That interfered with my second use of the loader and my own filter, unless the user had previously done a filter-based search and pressed the “Search” key.

I also discovered that the actual filter object leaves parameters defined if they have been used, even if you clear the value afterwards. For example, if you filter on field “name” and then clear the filter value for “name”, the paramenter “name” still exists in the loader parameters map. When you then try to do your own load, you get an SQL error because the “name” parameter is not in the query any longer.

The solution is to use:

loader.setParameters(new HashMap<>());    // clears out the parameter map removing filter params
loader.setParameter("myParam", myValue);  // set my parameter
loader.setCondition(null);                // clears out the JPQL "where 0<>0" from manualApplyRequired="true"

I did not see this in the documentation anywhere. Did I miss it?

I hope somebody else finds this useful.

Hello @eraskin!

You are right, the logic for using the filter was organized in exactly this way. Usually, the use of a generic filter component means that only it will control the loading of data on the screen.

As workaroud, you could set manualApplyRequired parameter to false and remove the @LoadDataBeforeShow annotation from the browser controller.

You could try to implement your own load by calling the filter delegate:

filter.getDelegate.refresh(Map /*new parameters*/);


Thank you.