我在Facelet模板中定义了标题,正文和页脚。我想在我的登录页面中隐藏页眉和页脚。我怎样才能做到这一点?
答案 0 :(得分:6)
其中一种方法是根据current view ID有条件地呈现它们。
<h:panelGroup id="header" layout="block" rendered="#{view.viewId != '/login.xhtml'}">
Header.
</h:panelGroup>
<div id="body">
<ui:insert name="body">Body.</ui:insert>
</div>
<h:panelGroup id="footer" layout="block" rendered="#{view.viewId != '/login.xhtml'}">
Footer.
</h:panelGroup>
另一种方法是使用<ui:param>
:
<h:panelGroup id="header" layout="block" rendered="#{not hideHeaderAndFooter}">
Header.
</h:panelGroup>
<div id="body">
<ui:insert name="body">Body.</ui:insert>
</div>
<h:panelGroup id="footer" layout="block" rendered="#{not hideHeaderAndFooter}">
Footer.
</h:panelGroup>
然后在/login.xhtml
的模板客户端中:
<ui:composition template="/WEB-INF/templates/layout.xhtml" ...>
<ui:param name="hideHeaderAndFooter" value="true" />
<ui:define name="body">
...
</ui:define>
</ui:composition>