I am trying to restrict certain pages in my web application to certain users, such as an administrator. However, I keep getting the following error:
Error Parsing: #{userSession.hasRole('ADMIN')}
I have tried several things but keep hitting a brick wall and was hoping someone may be able to shed some light.
My UserSession class has the following method:
public boolean hasRole(Role role)
{
return roles.contains(role);
}
I am also using the following Bean and session scope:
@ManagedBean(name="userSession")
@SessionScoped
Then, in my view, I am using:
<p:tab rendered="#{userSession.hasRole('ADMIN')}" title="Admin">
My Role class:
public class Role {
public enum RoleType {
ADMIN, USER
}
private RoleType type;
public setRoleType(RoleType type)
{
this.type = type;
}
public RoleType getRoleType(RoleType type)
{
return this.type;
}
}
As I am using a VM it's difficult for me to copy and paste my code onto here, but here are some screenshots of the stack trace:
https://i.stack.imgur.com/Slfh3.jpg
Any help is greatly appreciated.