Filter a foreign key field depending on the current user session
book
Article ID: KB0074664
calendar_today
Updated On:
Products
Versions
TIBCO EBX
All versions from 5.8.0.
Description
What is recommended for filtering a foreign field programmatically is to implement a TableRefFilter. However, this class being a constraint, it is executed outside the context of an authenticated user session. Thus we cannot retrieve a session object inside this class and so we cannot filter our combo box depending on it.
The solution to be able to filter a foreign key field depending on the current user session is to implement a custom widget.
Resolution
In our example, we use a data model that has two tables and there is a foreign key from "table" to "table1". In "table1", there is a "display" boolean field.
We want to filter a foreign key field depending on the following condition: the "display" target field is equal to true OR the current user is a built-in administrator.
Here is the implementation of the "write" method of the UISimpleCustomWidget: