Changes in MVCActionCommands and portletIds

This article documents changes to the MVCActionCommand type of commands after Liferay DXP 7.0 Fix Pack 11 is deployed. This change most affects developers building portlets in Liferay IDE tools (e.g. Liferay Developer Studio or Liferay Blade).

Before Fix Pack 11, developers did not have to declare; it was not necessary for MVCAction commands but only the Liferay DXP 7.0 generated portletId.

Once Fix Pack 11 was deployed, it was discovered that MVCAction commands no longer worked. The rationale was a change in the portal. Liferay DXP 7.0 generated a name for the portlet that did not match the underscored name defined in the PORTLET_NAME constant in the keys class. Therefore, MVCActionCommands will not be triggered.

If is not defined in the MVCPortlet, the result is when actions are invoked from MVCActionCommands (for example, AddRecordMVCActionCommand), the MVCPortlet ends up using the method getPortletName() from GenericPortlet and this name is post processed by the portlet container.


After Fix Pack 11, the has been added to each portlet classes in Liferay DXP 7.0 by default. See the following template from source:

package ${package}.portlet;

import ${package}.constants.${className}PortletKeys;

import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;

import javax.portlet.Portlet;

import org.osgi.service.component.annotations.Component;

 * @author ${author}
	immediate = true,
	property = {
		"javax.portlet.display-name=${artifactId} Portlet",
	service = Portlet.class
public class ${className}Portlet extends MVCPortlet {

Developers using Liferay Blade CLI tools will have to manually add this property to all portlets because this property is not included in the project templates. Once added to any custom portlet, this will resolve the issue of MVCActionCommands not being bound to the portlet. The next release should resolve this issue by including in all project templates.

Developers using Liferay Developer Studio will find that this property is already included in the project templates in the latest release. 

Additional Information

Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0