views:

164

answers:

2

Hi all!

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

A: 

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" />
Bozho
Hi Bozho, thanks for your reply.Unfortunately, <ui:param> value it's not recognised on the template page when defined on the page that uses template, inside a define tag :(
João Madureira Pires
use it outside the define tag. It is working perfectly in my current application.
Bozho
Yes, works outside the define tag. But i need the information inside the define tag to fulfil ui:parameter value :s
João Madureira Pires
that seems strange. What kind of information is that?
Bozho
A: 

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