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

ブール構造フィールドは、テンプレートで表示された場合、"False "ではなく、空の文字列を返します。

written-by

Michael Warren Young

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

問題

  • ユーザーは、次のようなコードを使用して、ブール値フィールドのデータを印刷するテンプレートを構成することができます:
    "Boolean: ${BooleanXXXX.getData()}"
  • Booleanフィールドがチェックされている場合、この文字列は "True "と表示されます。
  • ただし、Booleanフィールドがチェックされないままだと、テンプレートは "False "の代わりに空の文字列を出力します。

環境

  • DXP 7.1

解決策

  • これは、上記のコードに対するFreemarkerで期待される動作です。
  • 上記のコードの代わりに、以下のようにすれば、Booleanフィールドから「True」または「False」をプリントアウトすることができます:
    <#if getterUtil.getBoolean(BooleanXXXX.getData())>
    ${languageUtil.get(locale, "true")}
    <#else>
    ${languageUtil.get(locale, "false")}
    </#if>
did-this-article-resolve-your-issue

legacy-knowledge-base