留言板
permission to view a portlet
Am embedding a portlet inside another portlet using <liferay-portlet:runtime> tag. I want to check whether the logged in user has "VIEW" permission for this embedding portlet.
<! -- check permission -->
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
<! -- check permission -->
if user doesn't have permission, this embedded portlet should not be rendered. only main portlet should be rendered.
I have tried below code, but not worked.
ThemeDisplay td = ((ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY));
PermissionChecker pc = td.getPermissionChecker();
User loginUser = td.getUser();
String p_id = "1_WAR_calenderportlet";
boolean hasPermission = pc.hasPermission(loginUser.getUserId(), p_id, p_id, "VIEW");
if(hasPermission ){
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
}
any suggestions?
<! -- check permission -->
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
<! -- check permission -->
if user doesn't have permission, this embedded portlet should not be rendered. only main portlet should be rendered.
I have tried below code, but not worked.
ThemeDisplay td = ((ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY));
PermissionChecker pc = td.getPermissionChecker();
User loginUser = td.getUser();
String p_id = "1_WAR_calenderportlet";
boolean hasPermission = pc.hasPermission(loginUser.getUserId(), p_id, p_id, "VIEW");
if(hasPermission ){
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
}
any suggestions?
Hi,
You need to pass the groupId and not the userId as parameter for the method pc.hasPermission.
Regards,
You need to pass the groupId and not the userId as parameter for the method pc.hasPermission.
Regards,