我正在用jboss,seam,richfaces开发一个Web应用程序。
我正在使用template(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"/>
提前致谢
最佳答案
我不认为facelets会那样工作。它编译并读取模板。
因此,我认为您可以定义所需的定义,而不必关心嵌套。
即:
//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>
关于jsf - 如何在其他定义内设置定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2071787/