I am using JSF 2.0 and PrimeFaces 2.2.1. In my template.xhtml, I have a ui:insert component:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>A page</title>
</h:head>
<h:body>
<ui:insert name="content"></ui:insert>
</h:body>
</html>
In myPage.xhtml which uses the above template, I defined a <p:layout> component as following:
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./../template/template.xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:define name="content">
<p:layout>
<p:layoutUnit position="center">
Center unit
</p:layoutUnit>
<p:layoutUnit position="right" collapsible="true">
Right unit
</p:layoutUnit>
</p:layout>
</ui:define>
</ui:composition>
When I opened myPage.xhtml, I saw “Center unit” and “Right unit” but I didn’t see any layout rendered.
However, when I tried to put the <p:layout> component inside the template as following:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>A page</title>
</h:head>
<h:body>
<p:layout>
<p:layoutUnit position="center">
<ui:insert name="center"></ui:insert>
</p:layoutUnit>
<p:layoutUnit position="right" collapsible="true">
<ui:insert name="right"></ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
everything works perfectly. Any pages that use the 2nd template rendered the component as expected.
I’d be very grateful if someone could tell me what I have done wrong with the 1st template.
I don’t believe that it is possible to use
<p:layout>within<ui:define>.You can use a
<ui:insert>within a<p:layoutUnit>however: