22 November, 2016

Custom portlet configuration - DXP

Hello Folks,

Here I have tried to put all the possible steps which we would required to introduce custom portlet configuration.

1) Create new Liferay module using mvcportlet template
2) Define below highlighted property in your controller class:
        immediate = true,
        property = {

        service = Portlet.class
public class SamplePortletextends MVCPortlet {

3) Introduce custom interface for models with unique id as highlighted

            id = "com.sample.action.SamplePortletConfig "        )
        public interface SamplePortletConfig {
        deflt = "blue",
        required = false
    public String favoriteColor();

       deflt = "red|green|blue",
       required = false
    public String[] validLanguages();

    @Meta.AD(required = false)
    public int itemsPerPage();

Note :
  1. Meta.OCD: Registers this class as a configuration with a specific id. You can choose any string you want, but make sure it’s unique. A common pattern is to use the fully qualified class name.
  2. 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.

4) Create custom config action class

        configurationPid = "com.sample.action.SamplePortletConfig",
        configurationPolicy = ConfigurationPolicy.OPTIONAL, immediate = true,
        property = {
        service = ConfigurationAction.class
public class SamplePortletConfigAction extends DefaultConfigurationAction {

// processaction,render and include methods

5) Add below property in module bnd file
-metatype: *
 6) Introduce config.jsp with all possible fields which you want to configure

 Now check your configuration icon and see if custom configuration is available or not for that specific portlet.

Interesting right !!!!!!!  Enjoy Learning Osgi :)

Rate Me:

0 Discussion: