了解jsf ui:composition的目的 [英] understand the purpose of jsf ui:composition

查看:81
本文介绍了了解jsf ui:composition的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容的用处是什么?

What is the usefulness of the following?

<ui:composition template="template.xhtml">;

在使用<ui:composition>的模板客户端页面中,标记范围之外的所有内容都将被忽略,并且不包含在呈现的输出中"(JavaServerFaces 2.0,完整参考,第61页)

"In a template client page using <ui:composition>, anything outside of the bounds of a tag is ignored and is not included in the rendered output" (JavaServerFaces 2.0, the complete reference, pg.61)

由于<ui:define>之外的所有内容都将被忽略,因此为什么要在其中放置任何内容?无需在<ui:define>之外放任何东西.

Since everything outside <ui:define> is ignored, why put anything there? Nothing has to be put outside the <ui:define>.

但是这样做,我所得到的只是模板本身,只填充了一些可变"部分.

But doing so, all I get will be the template itself with only some "variable" parts filled.

似乎没什么大不了的. 我不明白的另一件事是,composition元素的template属性是可选的.没有引用模板,它代表模板客户端吗?

It seems not to be this big deal. Another thing I don't understand, is that template attribute of composition element is optional. What does it represent a template client without the reference to a template?

推荐答案

以下内容的用处是什么?

<ui:composition template="template.xhtml">

使用此方法,您可以声明使用具有占位符的基本模板来插入模板定义.这比反过来更有用.您需要在每页中一次又一次地包含例如页眉,页脚和/或菜单.使用模板,您无需执行此操作.它只是放在模板中.

With this you can declare to use a basic template which has placeholders to insert template definitions. This is more useful than doing it the other way round. You would need to include for example the header, footer and/or menu in every page again and again. With a template you don't need to do this. It just goes in the template.

在使用<ui:composition>的模板客户端页面中,标记范围之外的所有内容都将被忽略,并且不包含在呈现的输出中"(JavaServerFaces 2.0,完整参考,第61页)

"In a template client page using <ui:composition>, anything outside of the bounds of a tag is ignored and is not included in the rendered output" (JavaServerFaces 2.0, the complete reference, pg.61)

由于外部的所有内容都被忽略,为什么要在此处放置任何内容?无需在<ui:define>之外放置任何东西.

Since everything outside is ignored, why put anything there? Nothing has to be put outside the <ui:define>.

您不需要这样做.你怎么会好的,也许基础教程可以做到这一点,但这只是出于演示目的. 这不会包含在渲染的输出中" ,依此类推.另一方面,如果您碰巧使用了可视化编辑器,则将考虑<ui:composition> 之外的内容.另请参见那里一种无需构建整个项目即可运行JSF页面的方法?

You don't need to do so. Why would you? Okay maybe the basic tutorial does that, but that's just for demonstration purposes. "This will not be included in the rendered output" and so on. On the other hand, if you happen to use a visual editor, then the content outside <ui:composition> will be regarded. See also Is there a way to run a JSF page without building the whole project?

我不了解的另一件事是,composition元素的template属性是可选的.在没有引用模板的情况下,它呈现了什么模板客户端?

一个简单的包含文件,可以由<ui:include>包含.

A simple include file which you can include by <ui:include>.

这篇关于了解jsf ui:composition的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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