开发者

How to set a define inside other define

开发者 https://www.devze.com 2022-12-16 06:48 出处:网络
I\'m developing a web application in jboss, seam, richfaces. I\'m using a template(xhtml) as master page of all others and there i set two insert tags. <ui:insert name=\"head\"/>

I'm developing a web application in jboss, seam, richfaces.

I'm using a template(xhtml) as master page of all others and there i set two insert tags. <ui:insert name="head"/> <ui:insert name="body"/>

The problem is that in pages that use this master page as template, the <ui:define name="head">...</ui:define> must be defined inside the <ui:define name="body">...</ui:define>.

How can i do this?

Basically, what i want is to do the following:

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

the master page must return : <meta name="开发者_运维问答title" content="#{something.title}" /> on the <ui:insert name="head"/>

Thanks in advance


I don't think facelets work like that. It compiles and reads the template.

So I think you can just define how many definitions you want and dont care about nesting.

ie:

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

And when you want to use this template simply:

 <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>


You can use <ui:param> in order to define content on each page. For example

in the template:

<meta name="title" content="#{titleParam}" />

in the page that uses the template:

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

精彩评论

暂无评论...
验证码 换一张
取 消