I’m just learning CUBA, and trying to implement a filter that takes a selected ‘root’ record ID from a user settings page and applies it automatically on all browse screens necessary where the entity is related to the “root entity”.
I have created an interface with a method that returns the join string (how to reach the root entity from current one) for the filter and is implemented by the entities where this filtering is necessary.
Then i created a FilterLookup class that extends StandardLookup.
In one of the lifecycle hooks or events i would like to apply the filter condition to the default filter visible on all browse screens, or achieve filtering of the datasource in any other way.
So in the end to use this feature one would only need to implement the join returning method on the entity, and extend my FilterLookup instead of StandardLookup when creating a new screen.
My problem is that accessing the filter control’s datasource throws a null pointer exception - i tried to apply the filter on it in Init, BeforeShow events and by overriding InitActions method.
- What would be the best way to add a condition automatically to the filter?
- Applying the filter condition directly on the backend would be even better but i don’t know how to access the datasource of descendant lookup screens in a generic way.
- Or maybe my approach is flawed, and this should be implemented in an entirely different way?
Any help would be appreciated!