Jsf Facelets多级模板-ui:定义未渲染
我有两个基本模板,一个有侧菜单,一个没有,这两个模板都包含一个包含ui:insert标签的公共页面(模板比较大,下面是基本示例) 使用Mojarra,一切正常,但现在我已迁移到MyFaces,ui:insert标记被忽略,相关ui:define的内容不会呈现(即,“此处是我的结果”不会显示) 我是否应该以某种方式将include-page.xhtml指定为模板?我试过了Jsf Facelets多级模板-ui:定义未渲染,jsf,facelets,myfaces,Jsf,Facelets,Myfaces,我有两个基本模板,一个有侧菜单,一个没有,这两个模板都包含一个包含ui:insert标签的公共页面(模板比较大,下面是基本示例) 使用Mojarra,一切正常,但现在我已迁移到MyFaces,ui:insert标记被忽略,相关ui:define的内容不会呈现(即,“此处是我的结果”不会显示) 我是否应该以某种方式将include-page.xhtml指定为模板?我试过了 <ui:composition template="included-page.xhtml" /> 而不是
<ui:composition template="included-page.xhtml" />
而不是
<ui:include src="included-page.xhtml" />
但是丢失了CSS
希望有人能提出解决方案:)
非常感谢,
尼尔
my-page.xhtml
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templates/default-template.xhtml">
<ui:param name="title" value="My Title" />
<ui:define name="results">
Here are my results
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:insert name="results">
</ui:insert>
</ui:composition>
这是我的结果
default-template.xhtml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<title>#{title}</title>
</h:head>
<h:body>
<ui:include src="included-page.xhtml" />
</h:body>
</html>
#{title}
included-page.xhtml
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templates/default-template.xhtml">
<ui:param name="title" value="My Title" />
<ui:define name="results">
Here are my results
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:insert name="results">
</ui:insert>
</ui:composition>
该
应该是一个
<ui:decorate template="included-page.xhtml" />
但是如果included page.xhtml
本身没有在其他地方重用,我想知道为什么它不只是内联到主模板中
另见:
谢谢@BalusC-毫不奇怪,它现在可以工作了:)。“real”included-page.xhtml目前由两个不同的模板使用。