Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're basically using templating the wrong way. You're basically using them "the other way round" from how it's supposed to be done. The page which you called "my template page" should be opened by its URL in the browser, not the page which you called "a facelet template". Best to prevent this mistake in the future is to store pages which you specify in <code>&lt;ui:composition template&gt;</code> (and <code>&lt;ui:include src&gt;</code>) inside <code>/WEB-INF</code> folder, so that they can never be opened directly by accident (or by hackers).</p> <p>Here's a kickoff example which should work for your case:</p> <p><code>/WEB-INF/templates/template.xhtml</code>:</p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"&gt; &lt;h:head&gt; &lt;title&gt;&lt;ui:insert name="title"&gt;Default title&lt;/ui:insert&gt;&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;ui:insert name="top"&gt; &lt;ui:include src="/WEB-INF/templates/top.xhtml"&gt; &lt;/ui:insert&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p><code>/WEB-INF/templates/top.xhtml</code>:</p> <pre class="lang-html prettyprint-override"><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"&gt; &lt;p&gt;Some default content for top&lt;/p&gt; &lt;/ui:composition&gt; </code></pre> <p><code>/page.xhtml</code></p> <pre class="lang-html prettyprint-override"><code>&lt;ui:composition template="/WEB-INF/templates/template.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"&gt; &lt;ui:define name="title"&gt; New page title here &lt;/ui:define&gt; &lt;ui:define name="top"&gt; &lt;h2&gt;naglowek&lt;/h2&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p>Now, you should in your browser navigate to <code>/page.xhtml</code> (and thus not the template file).</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/4792862/how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets/4793959#4793959">How to include another XHTML in XHTML using JSF 2.0 Facelets?</a></li> <li><a href="https://stackoverflow.com/questions/9031811/which-xhtml-files-do-i-need-to-put-in-web-inf-and-which-not">Which XHTML files do I need to put in /WEB-INF and which not?</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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