• Configurable Portlet In Liferay 7 / Liferay DXP

    Posted on June 19, 2017 by Hamidul Islam in liferay 7.


    We can make our portlet configurable at runtime. Portlet Preferences are the key points of configurable portlet.In Liferay 7 or Liferay DXP the process of making configurable portlet is different from Liferay 6.2. In this article we will discuss portlet configuration on Liferay 7. We will create a sample portlet before enabling the portlet configuration.

    Use Case:

    Consider that we want to display weather information in our custom portlet. We want City and Temperature Unit(celsius  or fahrenheit) to be configurable through UI so that it can be configured by each user.

    Step 1 : Create a sample Portlet

    To create a portlet in Liferay 7, follow the below link

    Liferay 7-OSGI Module – MVC Portlet by Maven

    Step 2: Create Java interface for configuration

    This interface represents the configuration of the portlet. Please read the comments for better understandings.

    The above will create one interface in Liferay Control Panel. You can navigate Control Panel →System Settings →Other →Demo Configuration.

    Step 3: Create the portlet class

    In this step we will create the Portlet Class and refer com.proliferay.configuration.WeatherConfiguration (the id of the configuration) as created in the above Step 2. Below is the portlet class

    Step 4: Write the Configuration Action

    In this step we will write a class which extends DefaultConfigurationAction. For your reference you can click portlet gear icon →Configuration→Setup. Below code is responsible for Portlet Setup where by default configuration.jsp is rendered.  The portlet preferences are set in the process action.

    Step 5: Writing the configuration page

    Step 6: Add meta type in bnd.bnd 

    Open the bnd.bnd file and add the below 

    -metatype: *

    We must add this in the BND file. Because we are using OSGI Metatype (look Step 2

    TODO: Look the Control Panel & explore

    Control Panel →System Settings →Other →Demo Configuration.

    Screen Shot:


    Source Code Download:



Comments are closed.
%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.