You can give administrators and users a way to customize a portlet with portlet preferences. Portlet preferences can be added to any MVC Portlet to give users a UI to access and set their preferences.
Note, portlet preferences are properties that are stored separately from an application’s configuration. To learn more see Portlet Level Configuration.
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.
The JSP file uses <liferay-portlet:actionURL /> and <liferay-portlet:renderURL /> tags to construct URLs in the variables configurationActionURL and configurationRenderURL.
When someone submits the form, the configurationActionURL is invoked, which triggers the application’s processAction method with the color variable included as a request parameter.
A URL parameter named cmd is supplied indicating the purpose of the request. The value of the cmd parameter is update.
Create a custom configuration action class to be able to access the portlet’s preferences.
@Component(
property = "javax.portlet.name=com_acme_p1z2_web_internal_portlet_P1Z2Portlet",
service = ConfigurationAction.class
)
public class P1Z2ConfigurationAction extends DefaultConfigurationAction {
@Override
public void processAction(
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse)
throws Exception {
setPreference(
actionRequest, "color",
ParamUtil.getString(actionRequest, "color"));
super.processAction(portletConfig, actionRequest, actionResponse);
}
}
In the @Component annotation, specify the portlet the action class applies to with a property tag.
Add the processAction() method which reads the portlet preferences from the configuration form and stores them in the database. In the sample portlet, the method reads the color URL parameter and sets the value as a portlet preference.
This website uses cookies and similar tools, some of which are provided by third parties (together “tools”). These tools enable us and the third parties to access and record certain user-related and activity data and to track your interactions with this website. These tools and the informationcollected are used to operate and secure this website, enhance performance, enable certain website features and functionality, analyze and improve website performance, and personalize user experience.
If you click “Accept All”, you allow the deployment of all these tools and collection of the information by us and the third parties for all these purposes.
If you click “Decline All” your IP address and other information may still be collected but only by tools (including third party tools) that are necessary to operate, secure and enable default website features and functionalities. Review and change your preferences by clicking the “Configurations” at any time.
Visit our Privacy Policy