legacy-knowledge-base
公開されました Jul. 2, 2025

MVCActionCommandsとportletIdsの変更点

written-by

Justin Choi

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

learn-legacy-article-disclaimer-text

この記事は、Liferay DXP 7.0 Fix Pack 11の導入後、 MVCActionCommand タイプのコマンドの変更について説明しています。 この変更は、Liferay IDEツール(Liferay Developer StudioやLiferay Bladeなど)でポートレットを構築している開発者に最も影響を与えます。

Fix Pack 11以前では、開発者は javax.portlet.nameを宣言する必要はありませんでした。これはMVCActionコマンドでは必要なく、Liferay DXP 7.0が生成するportletIdのみでした。

Fix Pack 11の導入後、MVCActionコマンドが動作しなくなることが判明しました。 根拠はポータルの変更でした。 Liferay DXP 7.0は、ポートレットの名前を生成しますが、keysクラスのPORTLET_NAME定数で定義されたアンダースコア付きの名前と一致しませんでした。 そのため、MVCActionCommandsはトリガーされません。

javax.portlet.name でない場合、MVCActionCommand(例:AddRecordMVCActionCommand)からアクションが呼び出されると、MVCPortletはGenericPortletのgetPortletName()メソッドを使用してしまい、この名前はPortlet containerでポスト処理されます。

解像度

Fix Pack 11以降、Liferay DXP 7.0の各ポートレットクラスには、デフォルトで javax.portlet.name が追加されました。 ソースの次のテンプレートを参照してください:

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}
 */
@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true",
		"javax.portlet.display-name=${artifactId} Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.name="classNamePortletKeysclassName"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user"
	},
	service = Portlet.class
)
public class ${className}Portlet extends MVCPortlet {
}


Liferay Blade CLIツールを使用する開発者は、このプロパティがプロジェクトテンプレートに含まれていないため、すべてのポートレットにこのプロパティを手動で追加する必要があります。 任意のカスタムポートレットに追加すると、 MVCActionCommands がポートレットにバインドされない問題を解決します。 次のリリースでは、すべてのプロジェクトテンプレートに javax.portlet.name を含めることで、この問題を解決する必要があります。

Liferay Developer Studioを使用している開発者は、このプロパティが最新リリースのプロジェクトテンプレートにすでに含まれていることに気づくでしょう。

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base