Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should also check out <a href="https://facelets.java.net/" rel="nofollow noreferrer">Facelets</a>; there is a <a href="http://www.ibm.com/developerworks/java/library/j-facelets/" rel="nofollow noreferrer">good introductory article</a> on DeveloperWorks.</p> <p>The Facelets <code>&lt;ui:insert/&gt;</code> tag is comparable to the ASP.NET <code>&lt;asp:ContentPlaceHolder/&gt;</code> tag used in master pages; it lets you provide default content for that area of the page, but this can be overridden.</p> <p>To fill the Facelets template in another page, you start with a <code>&lt;ui:composition/&gt;</code> element that points to the template file. This is roughly equivalent to declaring the MasterPageFile attribute in an ASP.NET page.</p> <p>Inside the <code>&lt;ui:composition/&gt;</code> element, you use <code>&lt;ui:define/&gt;</code> elements to override the template defaults, similar to the way an <code>&lt;asp:Content/&gt;</code> tag is used. These elements can contain any kind of content - from simple strings to JSF elements.</p> <p>So, to bring it all together...</p> <p>In <em>master.xhtml</em>:</p> <pre><code>&lt;!-- HTML header content here --&gt; &lt;ui:insert name="AreaOne"&gt;Default content for AreaOne&lt;/ui:insert&gt; &lt;ui:insert name="AreaTwo"&gt;Default content for AreaTwo&lt;/ui:insert&gt; &lt;!-- HTML footer content here --&gt; </code></pre> <p>In <em>page.xhtml</em>:</p> <pre><code>&lt;ui:composition template="/WEB-INF/templates/master.xhtml"&gt; &lt;ui:define name="AreaOne"&gt;Here is some new content&lt;/ui:define&gt; &lt;ui:define name="AreaTwo"&gt; &lt;p&gt;Some new content here too&lt;/p&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p>And this will render as:</p> <pre><code>&lt;!-- HTML header content here --&gt; Here is some new content &lt;p&gt;Some new content here too&lt;/p&gt; &lt;!-- HTML footer content here --&gt; </code></pre> <p>You also get some other benefits with Facelets, such as the ability to reuse page components with different data.</p> <p>(Edited to provide more information.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload