简体   繁体   English

了解 jsf ui:composition 的用途

[英]understand the purpose of jsf ui:composition

What is the usefulness of the following?以下有什么用处?

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

"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:composition>的模板客户端页面中,标记边界之外的任何内容都将被忽略,并且不包含在呈现的输出中”(JavaServerFaces 2.0,完整参考,pg.61)

Since everything outside <ui:define> is ignored, why put anything there?既然<ui:define>之外的所有东西都被忽略了,为什么要放任何东西呢? Nothing has to be put outside the <ui:define> . <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?没有模板引用的模板客户端代表什么?

What is the usefulness of the following?以下有什么用处?

 <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.例如,您需要在每个页面中一次又一次地包含 header、页脚和/或菜单。 With a template you don't need to do this.使用模板,您无需执行此操作。 It just goes in the template.它只是在模板中。


"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:composition>的模板客户端页面中,标记边界之外的任何内容都将被忽略,并且不包含在呈现的输出中”(JavaServerFaces 2.0,完整参考,pg.61)

Since everything outside is ignored, why put anything there?既然外面的一切都被忽略了,为什么还要放任何东西呢? Nothing has to be put outside the <ui:define> . <ui:define>之外没有任何内容。

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.另一方面,如果您碰巧使用可视化编辑器,则将考虑<ui:composition>之外的内容。 See also Is there a way to run a JSF page without building the whole project?另请参阅有没有办法在不构建整个项目的情况下运行 JSF 页面?


Another thing I don't understand, is that template attribute of composition element is optional.我不明白的另一件事是组合元素的模板属性是可选的。 What does it rapresent a template client without the reference to a template?如果没有对模板的引用,它代表一个模板客户端是什么?

A simple include file which you can include by <ui:include> .一个简单的包含文件,您可以通过<ui:include>它。

See also:也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM