Front sides: how to pass the value of ui: insert as an html attribute?

I am trying to do a little tweaking in a Facelets / JSF environment. I know almost nothing about how it all fits together.

I have a value defined on different pages as "title"

<ui:define name="title">PageUID_123</ui:define> 

On another page, I refer to this as follows:

 <ui:insert name="title"/> 

I can wrap the html tags around the insert just fine, but I need to be able to output the "title" value as an attribute of another element. My ultimate goal is to render it in html like this:

 <meta name="pageid" content="PageUID_123"/> 

If I try to put the insert tag in the bit content = "", it throws a parsing error. Is there any way to do this?

+7
facelets jsf
source share
1 answer

I don’t have a working environment in front of me, but I believe that you do not want to use <ui:define> , but instead you want to use <ui:param> , and then use ${x} or #{x} (or forget what or if it matters) to pull them out.

So, for example, you would:

 <ui:param name="title" value="PageUID_123" /> 

And then:

 <meta name="pageid" content="${title}"/> 

My only concern is that you use include to have nice templates, i.e.

template:

 <html> <head> <meta name="pageid" content="${title}"/> </head> <body> <ui:insert name="content" /> </body> </html> 

Inner Page:

 <html xmlns="...so many"> <ui:param name="title" value="PageUID_123" /> <ui:define name="content"> <!-- content goes here --> </ui:define> </html> 

And I really don't know if this will fly ...

Edit: You might want to try ${title} or #{title} just to get started on how you are doing it now, it might just work.

+6
source share

All Articles