2015-01-15 19 views
1

我想在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> 

這是呈現給客戶端的內容。

output

爲什麼默認的內容和默認菜單欄未呈現?

回答

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> 
相關問題