掲示板

How to Hide/ Show a Button By Checking Permission

9年前 に kumari meenu によって更新されました。

How to Hide/ Show a Button By Checking Permission

Junior Member 投稿: 29 参加年月日: 14/02/05 最新の投稿
Hi ,
I want to apply permission on Button of custom portlet , There are certain features like showing a Add button for certain users only based on custom permissions define .
I created a custom portlet on which configured the permissions in default.xml file under resource-actions .

<portlet-resource>
		<portlet-name>Networking</portlet-name>
		<permissions>
			<supports>
				<action-key>ADD_ENTRY</action-key>
				<action-key>ADD_TO_PAGE</action-key>
				<action-key>CONFIGURATION</action-key>
				<action-key>VIEW</action-key>
			</supports>
			<site-member-defaults>
				<action-key>VIEW</action-key>
			</site-member-defaults>
			<guest-defaults>
				<action-key>VIEW</action-key>
			</guest-defaults>
			<guest-unsupported>
				<action-key>ADD_ENTRY</action-key>
				<action-key>CONFIGURATION</action-key>
			</guest-unsupported>
			<layout-manager>
				<action-key>VIEW</action-key>
			</layout-manager>
		</permissions>
	</portlet-resource>

But it doesn't work .
Please help ..
Thanks in Advance
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: How to Hide/ Show a Button By Checking Permission

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
That only defines the permissions, but it doesn't do anything to add permissions to the button.

That you accomplish in code, typically by using a permission checker to see if the current user has a necessary permission.
9年前 に kumari meenu によって更新されました。

RE: How to Hide/ Show a Button By Checking Permission

Junior Member 投稿: 29 参加年月日: 14/02/05 最新の投稿
David H Nebinger:
That only defines the permissions, but it doesn't do anything to add permissions to the button.

That you accomplish in code, typically by using a permission checker to see if the current user has a necessary permission.



Hi David ,
Thanks for the reply.
Could you elaborate a bit on how to use permission checker to apply permission on the button.

Regards
thumbnail
9年前 に Meera Prince によって更新されました。

RE: How to Hide/ Show a Button By Checking Permission

Liferay Legend 投稿: 1111 参加年月日: 11/02/08 最新の投稿
Hi
Have a look into following sample portlet it may help you..

https://github.com/liferay/liferay-plugins/tree/6.2.x/portlets/sample-permissions-portlet

The following code may be help you

<%= permissionChecker.hasPermission(groupId, name, primKey, actionId) %>

Regards,
Meera Prince
9年前 に kumari meenu によって更新されました。

RE: How to Hide/ Show a Button By Checking Permission

Junior Member 投稿: 29 参加年月日: 14/02/05 最新の投稿
Meera Prince:
Hi
Have a look into following sample portlet it may help you..

https://github.com/liferay/liferay-plugins/tree/6.2.x/portlets/sample-permissions-portlet

The following code may be help you

<%= permissionChecker.hasPermission(groupId, name, primKey, actionId) %>

Regards,
Meera Prince


Hi ,
Thanks for reply .
I am now able to work with permissions on Button of my custom Portlet .