在Facelet模板中定义了页眉、正文和页脚。我想隐藏页眉和页脚在我的登录页面。我怎样才能做到呢?
一种方法是根据当前视图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>