https://blog.csdn.net/zkn_CS_DN_2013/article/details/33717091
常与h:panelGrid,h:dataTable等标签连用。申明组件为标题或页脚。
在自己定义组件里。我们常可利用 f:facet 为组件加入特别的属性或处理,比如MyFaces提供的翻页组件就利用f:facet制作翻页工具条。
f:facet使用方法例:f:facet经常使用使用方法
<jsf组件>
<f:facet name="facet名">...jsf组件</f:facet>
</jsf组件>
在自己定义组件里使用f:facet时,能够使用UIComponent.getFacets().get("facet名")方法取得指定的facet组件:
(UIComponent) getFacets().get("facet名");
h:dataTable使用f:facet例:
<h:dataTable value="#{myBean.bookList}" var= "book" border="1px">
<h:column>
<f:facet name="header">
<h:outputText value="Title"/>
</f:facet>
<h:outputText value="#{book.title}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Price"/>
</f:facet>
<h:outputText value="#{book.price}"/>
</h:column>
</h:dataTable>
相应HTML代码:
<table border="1px">
<thead>
<tr>
<th>Title</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</tbody>
</table>
浏览器显示:
Title Name Hello World