Liferay 6 and below version: 


import com.liferay.util.portlet.PortletProps;

PortletProps.get("PORTLET_KEY");

Liferay DXP :

Older version approach is not working in DXP to overcome this we need to follow the below step.

Step 1:

Create class in your custom portlet as show below snippet.


import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil;

public class PortletPropsConfigurationUtil
{
public static String get(String key)
{
return _configuration.get(key);
}

public static String[] getArray(String key)
{
return _configuration.getArray(key);
}

private static final Configuration _configuration =
ConfigurationFactoryUtil.getConfiguration(PortletPropsConfigurationUtil.class.getClassLoader(), "portlet");
}

Step 2:


PortletPropsConfigurationUtil.get("PORTLET_KEY");

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: