I'm trying to accomplish a small tweak in a Facelets/JSF environment. I know next to nothing how all of it fits together.
I have a value defined on various pages as "title"
<ui:define name="title">PageUID_123</ui:define>
On another page I am referencing this with:
<ui:insert name="title"/>
I can wrap html tags around the insert just fine, but I need to be able to output the value of "title" as an attribute of another element. My end goal is for it to render in html like this:
<meta name="pageid" content="PageUID_123"/>
If I try putting the insert tag in the content="" bit, it throws a parsing error. Is there a way to do this?
-
I don't have a working environment in front of me, but I believe you don't want to you use
<ui:define>, but instead you want to use<ui:param>and then use${x}or#{x}(or forget which or if it matters) to pull them out.So, for you example you would have:
<ui:param name="title" value="PageUID_123" />And then:
<meta name="pageid" content="${title}"/>My only concern with that is that you are using 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 that will fly...
Edit: You may want to try
${title}or#{title}just for kicks the way you're doing it now, it might Just Work.Tim Büthe : In facelets it does not matter if you use ${x} or #{x}. They mean the same: https://facelets.dev.java.net/nonav/docs/dev/docbook.html#el
0 comments:
Post a Comment