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

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

问题描述

以下内容有何用处?

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

既然 之外的所有东西都被忽略了,为什么要在那里放任何东西? 之外无需放置任何内容.

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.

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

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.

在使用 的模板客户端页面中,标记边界之外的任何内容都将被忽略并且不包含在呈现的输出中"(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>.

你不需要这样做.你为什么要?好吧,也许基本教程就是这样做的,但这只是为了演示目的.这将不会包含在渲染的输出中" 等等.另一方面,如果你碰巧使用了可视化编辑器,那么<​​code>之外的内容会被视为.另请参阅 是否有一种无需构建整个项目即可运行 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?

我不明白的另一件事是组合元素的模板属性是可选的.没有模板引用的模板客户端有什么用?

一个简单的包含文件,您可以通过 包含它.

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

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

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