掲示板
permission to view a portlet
7年前 に Selva kumar によって更新されました。
permission to view a portlet
Junior Member 投稿: 39 参加年月日: 15/07/23 最新の投稿
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?
7年前 に Antoine Comble によって更新されました。
RE: permission to view a portlet
Regular Member 投稿: 232 参加年月日: 12/09/07 最新の投稿
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,
7年前 に Devang Patel によって更新されました。
RE: permission to view a portlet
Regular Member 投稿: 247 参加年月日: 15/01/19 最新の投稿
Hi Selva kumar,
I agree with Antoine you have to pass groupId.
You can pass primKey as long/String.
Regards,
Devang Patel
Antoine Comble:
You need to pass the groupId and not the userId as parameter for the method pc.hasPermission.
I agree with Antoine you have to pass groupId.
pc.hasPermission(long groupId,String name,String primKey,String actionId)
.You can pass primKey as long/String.
Regards,
Devang Patel