In order to have configurations at the portlet level in Liferay, we can implement portlet preference. In this example, we have implemented a color configuration for portlet in Liferay 7.2.


  • Java 
  • Liferay portal 7/7.x

Environment Requirement

  • JDK
  • Eclipse
  • MySQL

1. Create a module project with below classes.

Portlet Preferences in Liferay 7.2

2. Create a Java interface.


@Meta.OCD is used to register this class as a configuration with a specific id. The ID must be the fully qualified configuration class name.

@Meta.AD specifies the default value of a configuration field as well as whether it’s required or not. Note that if you set a field as required and don’t specify a default value, the system administrator must specify a value in order for your application to work properly. Use the deflt property to specify a default value.

This portlet requires the following dependencies.

compileOnly group: “biz.aQute.bnd”, name: “biz.aQute.bndlib”,version: “3.1.0”


3. Create an action class.

Configuration action class is required to access portlet preferences. This class must extend the DefaultConfigurationAction class. It is responsible for storing portlet configurations.

4. Implement your portlet class.

5. Now Implement your init.jsp.

6. Create configuration.jsp.

Add all configurations’s input fields in this JSP file.

7. Add the below code in your view.jsp.

  • Now, deploy this module.
  • Add your portlet to a Liferay page. 
  • Click on the ellipsis icon and select the option Configuration. 
  • Change the configuration and save it.
Portlet Preferences in Liferay 7.2
Portlet Preferences in Liferay 7.2