Configuration Framework

Portlet Level Configuration

With the configuration framework, you can set your application’s configuration for different levels of scope. Where Instance and Site-scoped configurations use ConfigurationProvider, portlet scoped configurations use PortletDisplay as shown in the example below.

The configuration framework can be used in conjunction with portlet preferences so that an app can have both a configuration UI in system settings as well a preference UI in the portlet’s setup tab.

Note, an application’s configuration is overridden if portlet preferences are implemented and set by a user. See Portlet Preferences to learn more.

See the Example Code

Start a new Liferay instance by running

docker run -it -m 8g -p 8080:8080 liferay/portal:7.4.3.132-ga132

Sign in to Liferay at http://localhost:8080. Use the email address test@liferay.com and the password test. When prompted, change the password to learn.

Then, follow these steps:

  1. Download and unzip Sharing Localized Messages.

    curl https://resources.learn.liferay.com/examples/liferay-x7y2.zip -O
    
    unzip liferay-x7y2.zip
    
  2. From the module root, build and deploy.

    ./gradlew deploy -Ddeploy.docker.container.id=$(docker ps -lq)
    
    Note

    This command is the same as copying the deployed jars to /opt/liferay/osgi/modules on the Docker container.

  3. Confirm the deployment in the Liferay Docker container console.

    STARTED com.acme.x7y2.web_1.0.0 [1651]
    
  4. Verify that the example module is working. Open your browser to https://localhost:8080

  5. Deploy the X7Y2 Portlet to a page. You can find the example portlet under Sample Widgets. Notice that the default color is set to green.

  6. Navigate to Global Menu (Global Menu) → Control Panel → System Settings. Click the X7Y2 configuration.

    Navigate to the application's configuration in system settings.

    Select and save a different default color. Navigate back to the page with the deployed widget. The color variable is now updated.

  7. Click the portlet’s options icon (Widget Options icon) in the widget header →