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:
-
Download and unzip Sharing Localized Messages.
curl https://resources.learn.liferay.com/examples/liferay-x7y2.zip -Ounzip liferay-x7y2.zip -
From the module root, build and deploy.
./gradlew deploy -Ddeploy.docker.container.id=$(docker ps -lq)NoteThis command is the same as copying the deployed jars to
/opt/liferay/osgi/moduleson the Docker container. -
Confirm the deployment in the Liferay Docker container console.
STARTED com.acme.x7y2.web_1.0.0 [1651] -
Verify that the example module is working. Open your browser to
https://localhost:8080 -
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.
-
Navigate to Global Menu (
) → Control Panel → System Settings. Click the X7Y2 configuration.
Select and save a different default color. Navigate back to the page with the deployed widget. The color variable is now updated.
-
Click the portlet’s options icon (
) in the widget header →