2016-11-08 99 views
0

我使用<ui:composition,但想知道是否有方法可以編輯我的一個佈局組件的一小部分,而無需在每個單獨的頁面上執行<ui:define>。在我的情況下,我創建了一個側邊欄,只是想要更改li的活動類。JSF ui:組合修改

commonlayout.xhtml

... 
<h:body> 
    <ui:insert name="sidebar"> 
     <ui:include src="commonsidebar.xhtml"/> 
    </ui:insert> 
</h:body> 
... 

commonsidebar.xhtml

... 
<ui:composition> 
    <div id="sidebar"> 
     <a href="#" class="visible-phone"> 
      <i class="icon icon-home"></i> Dashboard 
     </a> 
     <ul> 
      <li class="active"> 
       <a href="index.xhtml"> 
        <i class="icon icon-home"></i> <span>Dashboard</span> 
       </a> 
      </li> 
      <li> 
       <a href="seconpage.xhtml"> 
        <i class="icon icon-def"></i> <span>Second Page</span> 
       </a> 
      </li> 
     </ul> 
    <div id="sidebar"> 
</ui:composition> 
... 

secondpage.xhtml

... 
<ui:composition template="commonlayout.xhtml"> 
    ? 
</ui:composition> 
... 

我想保持我的側邊欄一樣在我的第二頁,但只將該設置更改爲<li>以激活,並且據我所知,<ui:define name="sidebar">會讓我重寫整個事情。 JSF中有什麼辦法可以做到這一點?

提前致謝!

回答