【问题标题】:Facelets multi-level templates - ui:define not renderedFacelets 多级模板 - ui:define 未呈现
【发布时间】:2012-10-22 05:10:27
【问题描述】:

我有 2 个基本模板 - 一个带有侧边菜单,一个没有 - 两个 ui:include 一个包含 ui:insert 标签的公共页面(模板很大,下面是基本示例)。

使用 Mojarra 一切正常,但现在我已经迁移到 MyFaces,ui:insert 标记被忽略,相关 ui:define 的内容不会被渲染(即“这里是我的结果”不显示)。

我应该以某种方式将included-page.xhtml 指定为模板吗?我试过了

<ui:composition template="included-page.xhtml" />

而不是

<ui:include src="included-page.xhtml" />

但丢失了 CSS。

希望有人可以提出解决方案:)

非常感谢,

尼尔

我的页面.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>

默认模板.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>

包含页面.xhtml

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

【问题讨论】:

    标签: jsf facelets myfaces


    【解决方案1】:

    &lt;ui:include&gt; 应该是 &lt;ui:decorate&gt;。

    <ui:decorate template="included-page.xhtml" />
    

    但如果 included-page.xhtml 本身没有在其他地方重用,我想知道为什么它不只是内联在主模板中。

    另见:

    【讨论】:

    • 感谢@BalusC - 毫不奇怪它现在可以工作了:)。 “真正的”included-page.xhtml 目前被 2 个不同的模板使用。
    猜你喜欢
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 2012-01-02
    • 2020-06-08
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多