How can we include multiple xhtml pages into a summary page. Here all the xhtml pages including same template.
<!DOCTYPE html>
<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:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title> SNS </title>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="sns.css" type="text/css" />
</head>
<h:body>
<div id="header">
<ui:insert name="commonHeader">
<ui:include src="header.xhtml" />
</ui:insert>
</div>
<div id="content">
<ui:insert name="commonBodyContent">
Common Body Content.
</ui:insert>
</div>
<div id="footer">
<ui:insert name="commonFooter">
<ui:include src="footer.xhtml" />
</ui:insert>
</div>
</h:body>
</html>
<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"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<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"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<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"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<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">
<ui:include src="updatePersonalDetails.xhtml" />
<ui:include src="updatedAddress.xhtml" />
<ui:include src="selectPreferences.xhtml" />
</ui:composition>
Whatever the data i have in all xhtml pages, supposed to display exactly same in summary page. But including this causes multiple <html>
documents to render on page.
How can we solve this ?
Move the body content into another template which you include by <ui:include>
in the template clients as well.
E.g. updatePersonalDetails.xhtml
<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"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
<ui:include src="updatePersonalDetails-content.xhtml" />
</ui:define>
</ui:composition>
(repeat for the others as well)
so that you can just do this in summary.xhtml
:
<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"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
<ui:include src="updatePersonalDetails-content.xhtml" />
<ui:include src="updatedAddress-content.xhtml" />
<ui:include src="selectPreferences-content.xhtml" />
</ui:define>
</ui:composition>
Unrelated to the concrete problem, consider placing templates and includes in /WEB-INF
folder to prevent them from being accessed directly. See also Which XHTML files do I need to put in /WEB-INF and which not?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With