Message Boards

Show and Hide Portlet Based on Role

Priyank Gajera, modified 7 Years ago.

Show and Hide Portlet Based on Role

New Member Posts: 2 Join Date: 4/23/16 Recent Posts
I am using Liferay 6.1 and Liferay MVC portlet

I have three regular role

1. admin
2. business
3. technical

There is one Liferay public page and there is one portlet on it let say PortletA. I have set portlet permission that portlet is visible to business and technical user but not the admin. the user can be part of more than one organization (this is NOT Liferay organization). and in each organization user can have the different role.

Now there is one drop down of organization on different portlet on the same page.
when I change the organization for a user, I perform following things.

1. when I select organization I make ajax call and based on organization I fetch role of the user from API.
2. Synchronize roles of the user based on fetched roles.
3. Clear Cache

MultiVMPoolUtil.clear();
WebCachePoolUtil.clear();
SingleVMPoolUtil.clear();

4. On ajax success Refresh the page using window.location.href

Now when a page is refreshed, Sometimes PortletA is visible to admin and sometimes it is not visible to business and technical user.

I have tested it with the user having only admin role in one organization and all three roles in another organization.

any suggestions?

Thanks in advance.