Read Portlet Preferences in Liferay

6 comments
We know how to get preferences of current portlet from request object (renderRequest.getPreferences()) but some time we have requirement to read preferences of remote portlet placed on some other page.


Using PortletPreferenceLocalServiceUtil we can read preference of any portlet. We just need to take care while passing parameter like OWNER_ID ,OWNER_TYPE , Plid , and Default Preferences.


If the preferences are unique per group 

OWNER_ID : PortletKeys.PREFS_OWNER_TYPE_GROUP

OWNER_TYPE : If the preferences are unique per group (Shared preferences between portlet placed on multiple page within same group) then pass groupId as OWNER_TYPE.

Plid : 0  (PortletKeys.PREFS_PLID_SHARED).

PortletId : PortletId of remote portlet.



If the preferences are unique per layout

OWNER_ID : PortletKeys.PREFS_OWNER_TYPE_LAYOUT

OWNER_TYPE : 0

Plid : Pass Plid of page where remote portlet is placed. If Blog portlet is placed on "/home" page then pass plid of "/home" page.

PortletId : PortletId of remote portlet.

Below is the example to read preferences of remote portlet.

In case if you are using any other method of PortletPreferecesLocalServiceUtil which returns com.liferay.portal.model.PortletPreferences instead of javax.portlet.PortletPreferences then using below code you can do the converstion from com.liferay.portal.model.PortletPreferences to javax.portlet.PortletPreferences.

Next PostNewer Post Previous PostOlder Post Home

6 comments:

  1. Hi Jitendra,

    I am Rashmi here working on Liferay. I am facing the below issue. Your help would be much appreciated.
    I logged in as admin and I have created new site site under organization org1, assigned the users user1 to it. Is there a way to restrict the same site should not be available to admin of other organization org2 ?
    I tried to create private/restricted site under org1 but its still appearing for the org2. Is there a way to restrict the site1 should not be available to Org2.
    Second issue, is there a way to restrict the users existing under org1 should not be available to admin of org2.

    ReplyDelete
    Replies
    1. Instead of assigning Administrator role please try by assigning organization role called 'Organization Adminstrator' to user. User having administrator can access all the organization and sites while organization adminstrator can only manage organization for which role has been granted.

      Delete
  2. Thanks a lot for reply. You mean need to assign organization role instead of user admin role. I will try this .
    How to restrict the site n user of other org ? Any specific site role need to be assigned ?
    Please reply.

    ReplyDelete
  3. Thanks a lot for reply. I will try this . Thank u again for timely help

    ReplyDelete
  4. Jitendra,
    One small query. After adding org administrator I am not able to see all the users under that org. Please let me know how to get only org users for which he belongs to?
    Thanks in advance. Waiting for reply.

    ReplyDelete
    Replies
    1. Can you please elaborate more ? You can see org members if any user is member of organization. Could you please try by assigning membership to user and then see.

      Delete