2014-01-09 80 views
0

jsf facelets可以做下一步嗎?inline define for include in jsf

我想與額外的HTML列

reusable.xhtml

<ui:composition> 
    <table class="table table-striped table-hover table-condensed"> 
     <thead> 
     <tr> 
      <ui:insert name="additional_headers"></ui:insert> 
     </tr> 
     </thead> 
     <tbody> 
     <c:forEach items="${beanChooser.chosenBean.entitiesToShow}" var="item"> 
     <tr id="#{beanChooser.chosenBean.shortEntityName.toLowerCase()}${item.id}"> 
      <td> 
      </td> 
      <td> 
      </td> 
      <ui:insert name="additional_columns"></ui:insert> 
     </tr> 
     </c:forEach> 
     </tbody> 
    </table> 
</ui:composition> 




<html> 
<ui:composition template="/masterTemplate.xhtml" ...> 
    <ui:define name="content"> 
     <ui:include src="../reusable.xhtml"> 
      <ui:define name="additional_columns"> 
       <td> 
        Additional EL Expression 
       </td> 
      </ui:define> 

      <ui:define name="additional_headers"> 
       <th> 
        STATIC 
       </th> 
      </ui:define> 
     </ui:include> 
    </ui:define> 
</ui:composition> 
</html> 

如果這不是不可能延長reusable.xhtml,什麼是實現這一目標的最佳做法?

回答

2

我想你需要的是<ui:decorate>,而不是<ui:include>(檢查出<!-- HERE -->標記):

<ui:composition template="/masterTemplate.xhtml" ...> 
    <ui:define name="content"> 
     <ui:decorate template="../reusable.xhtml"><!-- HERE --> 
      <ui:define name="additional_columns"> 
       <td> 
        Additional EL Expression 
       </td> 
      </ui:define> 

      <ui:define name="additional_headers"> 
       <th> 
        STATIC 
       </th> 
      </ui:define> 
     </ui:decorate>       <!-- HERE --> 
    </ui:define> 
</ui:composition> 
+0

感謝,這正是我需要 – Lostboy

+0

它可以使用$ {item.field}裏面定義,萬一當reusable.xhtml包含? – Lostboy

+0

你的意思是像' $ {item.field}'?即裏面的'$ {item.field}'解開了嗎?我不記得,但如果沒有,你總是可以把它包裝在''中。 –