This is a limitation Liferay's implementation of the Portlet API. Specifically, the com.liferay.portlet.PortletRequestImpl.isUserInRole(String role) method delegates to the RoleLocalServiceImpl.hasUserRole(long userId, long companyId, String name, boolean inherited) method, which only checks for regular (portal scoped) roles. In other words, it does not have the ability to check for site role membership.
My recommendation would be that you use the rendered attribute instead, and use an EL-expression to test for role membership yourself.
For example in your Facelet view:
1<h:outputText value="some text" rendered="#{backingBean.userPermitted}" />
And in BackingBean.java:
1
2@RequestScoped
3public class BackingBean {
4
5 private Boolean userPermitted;
6
7 public boolean isUserPermitted() {
8 if (userPermitted == null) {
9 userPermitted = ...; // determine if user has site role
10 }
11 return userPermitted;
12 }
13}
Alternatively, if you are checking Liferay portlet permissions (not model permissions), you can use the Liferay Faces Portal dependency to do things like this:
1<h:outputText value="some text" rendered="#{liferay.userHasPortletPermission['some_portlet_permission_name']}" />
Be kell jelentkezni ahhoz, hogy ez helytelenként legyen megjelölve.