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 <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?
Tag composition. Defines a composition that optionally uses a template, as outlined in the description of the ui tag library. Multiple compositions can use the same template, thus encapsulating and reusing layout.
Use ui:insert and ui:include tag to include header/footer and content file in template file. Name each section in ui:insert tag. name attribute of ui:insert tag will be used to replace the contents of the corresponding section.
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>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With