JSF/Primefaces: ui:insert in ui:include
13,095
The solution is to include the footer.xhtml in the template.xhtml by
<ui:decorate template="footer.xhtml" />
Then the insert/define is working!
More info here: What is the real conceptual difference between ui:decorate and ui:include?
Author by
OPaczkowski
Updated on June 04, 2022Comments
-
OPaczkowski almost 2 years
I want to use ui:insert/ui:define to replace some content in a template file. Inside the template file there is an include of another file and inside this file is the ui:insert
The ui:define is not working in this case. If however the code of the footer.xhtml file is included in the template.xhtml the ui:define is working fine.
Is it not possible to use ui:insert/ui:define inside an ui:include?
template.xhtml:
<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:f="http://java.sun.com/jsf/core" xmlns:sec="http://www.springframework.org/security/facelets/tags" xmlns:debug="http://XYZ/jsf/debug" xmlns:util="http://XYZ/ibk/util" xmlns:p="http://primefaces.org/ui"> <h:body > <f:view> <div id="headerWrapper"> <!-- META-NAVIGATION --> <div id="metanavWrapper" > <div class="ui-helper-clearfix pagewidth" > <ui:include src="metanav.xhtml" /> </div> </div> </div> <div id="contentWrapper" > <!--div id="content" class="pagewidth"--> <div id="content"> <div id="contentMenuLeft"> <ui:include src="navigationMenu.xhtml" /> </div> <div id="contentDisplay"> <ui:insert name="content" /> <ui:insert name="help" /> </div> </div> </div> <util:footer /> </f:view> <ui:insert name="dialog"/> </h:body> </html>
--
<util:footer />
could also be written as ui:include, results in the same...
footer.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:sec="http://www.springframework.org/security/facelets/tags" xmlns:p="http://primefaces.org/ui" > <div id="footerWrapper"> <f:subview id="footerWrapper"> <h:panelGroup id="footer" > <div > <ui:insert name="replace" /> </div> </h:panelGroup> </f:subview> </div> </ui:composition>
another.xhtml: (snippet)
<ui:composition template="template.xhtml"> <ui:define name="replace"> <h:panelGroup> <div> <p:outputLabel value="test"/> </div> </h:panelGroup> </ui:define> </ui:composition>