テンプレート定義<ui:define>
を で上書きする方法に規則はありますか<ui:insert>
。
テンプレート A:
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets">
template A content<br/>
<ui:insert name="content"/>
</ui:composition>
テンプレート B:
<ui:composition template="/resources/templates/A.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="content">
template B content<br/>
<ui:insert name="content"/>
</ui:define>
</ui:composition>
サイト 1:
<ui:composition template="/resources/templates/B.xhtml">
Site 1<br/>
<ui:define name="content">
site content<br/>
</ui:define>
</ui:composition>
出力:
Site 1
site content
のコンテンツは<ui:define>
サイト 1 から取得され、テンプレートのコンテンツはレンダリングされません。
サイト 2:
<ui:composition template="/resources/templates/B.xhtml">
Site 2<br/>
</ui:composition>
出力:
Site 2
template B content
template A content
のコンテンツは<ui:define>
テンプレート B とテンプレート A から取得されます。奇妙なことに、テンプレート B のコンテンツはテンプレート A のコンテンツの前にレンダリングされます。
同名<ui:define>
で新規で上書きすることはできますか?<ui:insert>
ネストされたものに新しい名前を作成すること<ui:insert>
は 1 つの可能性ですが、階層と挿入が使用されている場所を追跡するのは困難です。