Cookies help us deliver our services.

By using our services, you agree to our use of cookies. Learn more

I understand

One of the features provided by the portal is the ability to define a properties file inside a custom plugin. 

Let's see how to define the file and how to read the values ​​within Liferay 6.2.

It'a all quite simple; first of all we must define the WEB-INF/src/ file where we'll define the needed properties:,5,10

After that we create the PortletPropsKeys interface in which we'll define all the constants that represent the names of the various properties:

public interface PortletPropsKeys {
    public static final String MY_INTEGER_PROPERTY = "";
    public static final String MY_STRING_PROPERTY = "";
    public static final String MY_LONG_ARRAY_PROPERTY = "";

Finally goes the PortletPropsValues class that will provide the access to the properties:

public class PortletPropsValues {
    public static final int MY_INTEGER_PROPERTY =
    public static final String MY_STRING_PROPERTY =
    public static final long[] MY_LONG_ARRAY_PROPERTY =

The access to the property goes through the PortletProps portal class and through the GetterUtil class to convert the string values ​​into what you need. 

At this point you can use the properties at any point in the code, directly through the class PortletPropsValues​​:

if(PortletPropsValues.MY_INTEGER_PROPERTY > 50) {
if(PortletPropsValues.MY_STRING_PROPERTY.equals("Hello")) {
for(long value: PortletPropsValues.MY_LONG_ARRAY_PROPERTY) {