Note that there are some explanatory texts on larger screens.

plurals
  1. POFacelet template renders two HTML tags
    primarykey
    data
    text
    <p>I am creating my first facelets/JSF application. In my first page I added a facelet template:</p> <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html 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;f:view&gt; &lt;h:head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/h:head&gt; &lt;body&gt; &lt;ui:insert name='top'&gt; &lt;ui:include src="/templates/template_a.xhtml"&gt;&lt;/ui:include&gt; &lt;/ui:insert&gt; &lt;/body&gt; &lt;/f:view&gt; &lt;/html&gt; </code></pre> <p>This is my template page:</p> <pre class="lang-html prettyprint-override"><code> &lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html 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;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/h:head&gt; &lt;body&gt; &lt;ui:composition template="/inwert_a.xhtml"&gt; &lt;ui:define name="top"&gt; &lt;h2&gt;naglowek&lt;/h2&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But when I look at page source in my web browser I see this: </p> <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;naglowek&lt;/h2&gt; &lt;/body&gt; &lt;/html&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Why does JSF create a body and other HTML tags twice when I am using <code>&lt;ui:composition&gt;</code>?</p> <hr> <p>After update my code looks that-main page:</p> <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html 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;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;f:subview id="a"&gt; &lt;ui:insert name="top"&gt; &lt;ui:include src="aaa.xhtml" &gt;&lt;/ui:include&gt; &lt;/ui:insert&gt; &lt;/f:subview&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>template content:</p> <pre class="lang-html prettyprint-override"><code>&lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" template="/mainpage.xhtml" &gt; &lt;ui:define name="top"&gt; &lt;h2&gt; aaaaaaaaa &lt;/h2&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p>this is source view: </p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;aaaaaaaaa&lt;/h2&gt; &lt;/body&gt; &lt;/html&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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. 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