understand the purpose of jsf ui:composition

橙三吉。 提交于 2019-11-27 09:30:25
BalusC

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

Since everything outside is ignored, why put anything there? Nothing has to be put outside the <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. See also 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?

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

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!