I came across a requirement where in I need to control view criteria hint(Display/Hide) based on logged in user or some user parameter.
I will now discuss & show a reusable way of controlling at a single point.
Model:
In EmployeeVO, I have defined a view criteria for employee search as below.
Department Id is a list of values defined on DepartmentVO.
I will show case here how to control display of DepartmentId LOV based on logged in user role.
I created EmployeeVOImpl & overridden below method:
If you notice, getCriteriaItemAttributeHints calls a Util method to determine whether to display/hide view criteria item based on logged in users role. If user is in role "super-user" then the Department Id LOV is displayed otherwise hidden.
For testing purpose, I enabled security in application & defined two test user & roles as below.
Now when I login as user barber, I don't see the Department Id LOV:
If I login as scott, I do see Department Id LOV:
Hope this helps!!!
No comments:
Post a Comment