Issue
- We've create a new Spring MVC Portlet and we'd like to configure it with some custom portlet preference. How can we do it?
Environment
- Liferay DXP
Resolution
Once you've created your Spring MVC Portlet you need to follow below steps in order to add some custom preferences to it:
- Create a configuration.jsp file. You can add some sample content like:
<h1>Test Config</h1>. Modify portlet.xml file to indicate where that config file is and mark it as config-template, it is to say, adding to your portlet.xml something like:
<init-param>
<name>config-template</name>
<value>/configuration.jsp</value>
</init-param>
- Modify your liferay-portlet.xml adding the required configuration-action-class as it is explained in the section Creating a Default Setup Tab in the Portlet’s Configuration Page. For a proof of concept you can just use the class DefaultConfigurationAction provided by Liferay. In other case, you need to create your custom configuration action class extending that one.
- After that, you can build and deploy your portlet, and once you click on configuration option you'll be able to see the title "Test Config".
- Once you are in that point, we recommend you to read those two articles we linked below and have a look at this Configuration Action Blade Sample to see how you can continue in case you need further help.