Multiple Spring MVC Portlets names are not displayed in Add Widget menu when added in the same WAR file
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- When creating custom widgets, if multiple widgets are deployed within the same war file, the individual names of the widgets are not seen in the Add Widget menu within Liferay
- Instead, each widget shares the same name
Resolution
- This occurs if a widget specific name is not defined in the Language.properties file.
-
When fetching a widget's name, the following code is executed: https://github.com/liferay/liferay-portal/blob/7.3.x/portal-impl/src/com/liferay/portal/util/PortalImpl.java#L8599-L8617. Liferay will first search the language file for a key specific to each widget deployed in the WAR file.
-
For example, it may be looking for the following two keys:
javax.portlet.title.testportlet_WAR_testportlet
javax.portlet.title.myportlet_WAR_testportlet
-
If these have not been defined in the Language.properties file, Liferay will fall back on the generic title key defined, by default:
javax.portlet.title=test-portlet
This is why both widgets may show the generic title in the Add Widget menu.
-
In order to have a unique title appear, the following keys (example shown) must be added to /test-portlet/src/main/resources/content/Language.properties
javax.portlet.title.testportlet_WAR_testportlet=The Test Portlet Title
javax.portlet.title.myportlet_WAR_testportlet=The My Portlet Title
This file is generally located at /WEB-INF/classes/content/Language.properties.
Did this article resolve your issue ?