私のフォームには、追加と更新の見出しとボタン テキストを表示する if-else 条件があります。
以下のコードは、struts2 プロジェクトで使用したものと同じコードを xhtml ページの JSF2 プロジェクトで使用したいものです。
Struts2 ページ
<s:if test="person==null || person.id==null || person.id==''">
<s:set var="buttonText" value="getText('person.button.add')"/>
<s:text name="person.h1.add.text"/>
<i><s:text name="person.smallfont.add.text"/></i>
</s:if>
<s:else>
<s:set var="buttonText" value="getText('person.button.edit')"/>
<s:text name="person.h1.edit.text"/>
<s:text name="person.smallfont.edit.text"/>
</s:else>
xhtml ページで JSTL を使用し、上記のコードをそのまま使用することもできますが、以下の EL を使用するなど、さまざまなアプローチが見られました。よくわかりませんが、以下のアプローチは好きではありません
<h:outputLabel value="Add Information" rendered="#{!empty personBean.person.id}" />
<h:outputLabel value="Use the form below to add your information." rendered="#{!empty personBean.person.id}" />
<h:outputLabel value="Update Information" rendered="#{empty personBean.person.id}" />
<h:outputLabel value="Use the form below to edit your information." rendered="#{empty personBean.person.id}" />
私の質問:
JSF プロジェクトの IF-ELSE 条件で上記のコードを使用する方法を教えてください。EL/JSTL またはその他を使用しますか?