Multiple Spring MVC Portlets names are not displayed in Add Widget menu when added in the same WAR file

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

Environment

  • Liferay DXP 7.3

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.
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0