Provide example for filter with relation in paramWhere paramClass

I have an entity that is linked to a user (the assignee) I now want to specify a custom filter with a parameter on users. The options for the parameter should be limited based on the roles.

<custom caption="Filter Expert" join="join {E}.expertises ex" name="expertFilter" paramClass="com.haulmont.cuba.security.entity.User" paramWhere="{E}.userRoles.role.name = ''">
                ex.expert = ?
</custom>

This is code is not valid due to the one-to-many userRoles (needs a join).

There’s multiple solutions here

  • paramJoin similar to the <custom join="?> (or more control over the param jpql)
  • programatically set the lookupfilter optionscontainer (how to get the lookupfilter component?)
  • specify a datacontainer for parameters

I can’t pinpoint exactly how to do this.

any tips or tricks on this one?

Hi,
I suppose what you need is not currently possible with generic Filter component without overriding its logic and writing custom code. There’s just not enough extension points in the Filter.

Your options are:

  1. Don’t use generic Filter component. Write simple filter by putting several components on a browser screen and fully controlling them (like in Entity Log screen).

  2. Step to the dark side by overriding FilterDelegateImpl, investigating how it works and hacking there to customize behavior.
    Look here how to override the bean: About filter componet access restrict - #3 от пользователя gorbunkov - CUBA.Platform
    I think that with enough time spent, pressure of business requirements and probably even use of Reflection API it is possible to achieve what you need.