2010-01-15 37 views
3

我正在開發一個在jboss,seam,richfaces中的web應用程序。如何在其他定義中設置一個定義

我使用模板(xhtml)作爲所有其他主頁面,並且在那裏設置了兩個插入標籤。 <ui:insert name="head"/> <ui:insert name="body"/>

的問題是,在使用該母版頁爲模板頁,<ui:define name="head">...</ui:define>必須在<ui:define name="body">...</ui:define>中定義。

我該怎麼做?

基本上,我想是做到以下幾點:

<ui:define name="body">... <ui:define name="head"> <meta name="title" content="#{something.title}" /> </ui:define> ...</ui:define>

母版頁必須返回:<meta name="title" content="#{something.title}" /><ui:insert name="head"/>

在此先感謝

+0

爲什麼你會不得不窩UI:定義標籤?有機會,你只會認爲你是。 –

回答

0

您可以使用<ui:param>爲了在每個頁面上定義content。例如

模板

<meta name="title" content="#{titleParam}" /> 
在使用模板的頁面

<ui:param name="titleParam" value="customValueForThisPage" /> 
+0

嗨Bozho,謝謝你的回覆。 不幸的是,在使用模板的頁面上定義模板頁面時,無法識別該模板頁面,它在define tag內部使用:( –

+0

在define tag外部使用它,它在我當前的應用程序中完美地工作 – Bozho

+0

是的, define tag。但是我需要定義標籤中的信息以滿足ui:參數值:s –

1

我不認爲小面的工作那樣。它編譯並讀取模板。

所以我認爲你可以定義你想要多少個定義,而不需要關心嵌套。

即:

//In your template.xhtml 
<ui:insert name="outer"> 
    BLA BLA BLA 
    <ui:insert name="inner"/> 
    BLA BLA BLA 
</ui:insert> 

而當你想使用這個模板簡單:

<ui:define name="outer"> 
    Here you can overwrite outer (This will probably overwrite inner, not sure, you need to test it) 
</ui:define> 

<ui:define name="inner"> 
    Or you can ONLY overwrite inner here if you want 
</ui:define> 
相關問題