Wednesday, September 24, 2014

[Liferay] Get preferences of another portlet | Get preferences of Portlet A in Portlet B

Hi,

Sometimes, we need to get preferences of a portlet into another portlet and take action appropriately.

Here is a snippet on how to do so. Suppose we have portlets A and B. We need preferences of A in B.
We can use dynamic query to get all the preferences of the portlet. From B we can use the code below. Replace myportletA with the correct porltetId.

We need to convert com.liferay.portal.model.PortletPreferences to javax.portlet.PortletPreferences to use getValue() or getValues() method.
Hope this helps someone.
Cheers!!!

1 comment:

Note: Only a member of this blog may post a comment.