Facelets多级模板-ui:define未呈现 [英] Facelets multi-level templates - ui:define not rendered

查看:121
本文介绍了Facelets多级模板-ui:define未呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个基本模板-一个带有侧面菜单,一个没有-都ui:包括一个包含ui:insert标签的公共页面(模板比较大,所以下面是基本示例).

I have 2 basic templates - one with a side menu, and one without - that both ui:include a common page which contains ui:insert tags (templates are largish, so basic example below).

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

Using Mojarra everything worked ok, but now I have migrated to MyFaces the ui:insert tags are ignored and the content of the related ui:define does not get rendered (i.e. 'Here are my results' is not displayed).

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

Should I be specifying included-page.xhtml as a template somehow? I tried

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

代替

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

但是丢失了CSS.

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

Hoping someone can suggest a solution :)

非常感谢,

尼尔

my-page.xhtml

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>

default-template.xhtml

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>

included-page.xhtml

included-page.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>

推荐答案

<ui:include>应该是<ui:decorate>.

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

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

But if the included-page.xhtml is by itself not reused elsewhere, I wonder why it isn't just been inlined in the master template instead.

  • Difference between ui:composition and ui:decorate in Facelets
  • What is the real conceptual difference between ui:decorate and ui:include?

这篇关于Facelets多级模板-ui:define未呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆