我正在尝试在JSF 2.2中编写复合组件。
就是这样。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite">
<!-- INTERFACE -->
<cc:interface>
<cc:facet name="content"/>
<cc:facet name="menubar"/>
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
Content header
<cc:renderFacet name="content">
This is the default content.
</cc:renderFacet>
Spacer
<cc:renderFacet name="menubar">
This is the default menubar.
</cc:renderFacet>
</cc:implementation>
</html>
这就是它的使用方式。
<dd:dummy>Hello hello</dd:dummy>
这是呈现给客户的内容。
为什么默认内容和默认菜单栏没有呈现?
答案 0 :(得分:1)
这应该有效
<cc:implementation>
<c:if test="#{empty component.facets.content}" >
This is the default content.
</c:if>
<c:if test="#{not empty component.facets.content}">
<cc:renderFacet name="content"/>
</c:if>
<c:if test="#{empty component.facets.menubar}" >
This is the default menubar.
</c:if>
<c:if test="#{not empty component.facets.menubar}">
<cc:renderFacet name="menubar"/>
</c:if>
</cc:implementation>