Archive for December, 2017

Liferay DXP – Fetch value from portelt.propertes

 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