Reputation:
I have a menu item that I want to show/hide only if the user has certain roles.
I'm using the rendered attribute for this, but I'm stuck on something. This works ...
rendered="#{loginHandler.hasStaffRole}"
... but this does not ...
rendered="#{loginHandler.hasStaffRole or loginHandler.hasInstructorRole or loginHandler.hasVolunteerRole}"
The error I get in Eclipse for the problem one is:
"cannot apply expression operators to method bindings"
Any idea how I should fix this?
Upvotes: 4
Views: 4414
Reputation: 939
I had the same issue:
rendered="#{user.canEdit or user.isRole('ROLE_1', 'ROLE_2')}"
The "solution" for my Eclipse 4.3 was to reverse the arguments: rendered="#{user.isRole('ROLE_1', 'ROLE_2') or user.canEdit}"
Adding parentheses did not cure it. Your mileage may vary.
Upvotes: 1
Reputation:
Answering my own question. The problem was the LoginHandler.hasStaffRole() method needed to be worded LoginHandler.isHasStaffRole() in order to be recognized as a property. (In the end I changed it to .isUserHasStaffRole.)
Thanks.
Upvotes: 8