templates - 了解jsf ui的用途 :composition

标签 templates jsf facelets

以下有什么用处?

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

“在使用 <ui:composition> 的模板客户端页面中,标记范围之外的任何内容都将被忽略,并且不包含在呈现的输出中”(JavaServerFaces 2.0,完整引用,pg.61)

由于一切在<ui:define>被忽略了,为什么要放任何东西呢?在 <ui:define> 之外没有任何内容。 .

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

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

最佳答案

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)

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


你不需要这样做。你为什么要?好吧,也许基本教程就是这样做的,但这只是为了演示目的。 “这不会包含在渲染的输出中”等等。另一方面,如果您碰巧使用可视化编辑器,那么 <ui:composition> 之外的内容被视为。另见 Is there a way to run a JSF page without building the whole project?

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?


一个简单的包含文件,您可以通过 <ui:include> 包含它.
也可以看看:
  • How to include another XHTML in XHTML using JSF 2.0 Facelets?
  • 关于templates - 了解jsf ui的用途 :composition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6525050/

    相关文章:

    c++ - std::accumulate 有引用吗?

    jsf - 如何呈现从选择 p :panel, 触发的 p :selectonemenu?

    jsf - ui :repeat in jsf 1. 2 中的 varstatus 属性

    jsf-2 - 用户界面 :repeat doesn't work with f:selectItem

    java - 使用java创建动态rich :panelMenu

    email - Grails邮件插件:查看的绝对路径

    c++ - 从成员函数类型中删除 const 的特征?

    java - NetBeans 无法识别许可证模板中的 ${project.organization}

    java - JSF 2.0 - 移动和 PC 浏览器的两个界面

    spring - GWT 前端的最佳 java webframe 后端?