legacy-knowledge-base
公開されました Sep. 10, 2025

TemplatePortletPreferences.reset() は利用できません

written-by

Daniel Couso

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

問題

  • 次のコードを含む以前のバージョンの Web コンテンツ テンプレートがレンダリングされます。
<#assign journalArticlePreferencesMap = {
"portletSetupPortletDecoratorId": "barebone",
"groupId": "54321",
"articleId": "12345"
}/>

<#assign journalArticlePreferences = freeMarkerPortletPreferences.getPreferences(journalArticlePreferencesMap) />

<@liferay_portlet["runtime"]
defaultPreferences="${journalArticlePreferences}"
instanceId="myEmbeddedContent"
portletProviderAction=portletProviderAction.VIEW
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet"
/>

<#assign VOID = freeMarkerPortletPreferences.reset() />
  • ただし、次のエラーが表示されます。
The following has evaluated to null or missing:
==> freeMarkerPortletPreferences.reset  [in template "20101#20128#36309" at line 16, column 17]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: #assign VOID = freeMarkerPortletPrefe...  [in template "20101#20128#36309" at line 16, column 1]

Environment

  • Liferay DXP 7.2+

解決策

  • メソッド reset from TemplatePortletPreferences class が Liferay DXP 7.2 以降では使用できなくなったため、エラーがスローされます。
  • 一部のユーザーは、このメソッドを呼び出して、UI を介してポートレットの設定を再構成することなく、その場でポートレットの設定を変更していました。
  • 引き続きこの効果を得たい場合は、回避策として、属性 instanceId の値を記事 ID に基づく値に変更できます。

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base