I have a ui:composition
that sits within a template, and I want to repeat an element both in template and the composition itself.
Here's an example.
template.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<h:head>
<title>JSF 2.0 Hello World</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</h:head>
<h:body>
<div class = "header">
<div class = "mylogo"></div>
HEADER
<!-- I want this content logo to be defined within module.xhtml-->
<ui:insert name = "content-logo"></ui:insert>
</div>
<div class = "content">
<ui:insert name = "content"></ui:insert>
</div>
<div class ="footer">
FOOTER
</div>
</h:body>
</html>
module.xhtml
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
template="template.xhtml">
<!-- define the module content-logo here-->
<ui:define name ="content-logo">
<div class ="another-logo"> foo</div>
</ui:define>
<ui:define name ="content">
<-- we also want to display the content-logo here-->
<ui:insert name = "content-logo"/>
<div class = "foo">
My main content
</div>
</ui:define>
</ui:composition>
The defined content-logo will display within the template header fine - but it doesn't display in the composition body. Is there a way I can make this work without resorting to copying the HTML?