I am using page templates in my application so I am using <ui:composition>
, <ui:insert>
and <ui:define>
. For the title of the pages, I am following the same thing mentioned by BalusC here; but the title remains the same on each page. When I see the page source, the actual title is there. How can it happen that the title bar shows the same title on each page but the page source has the correct page title?
The template page MainTemplate.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<h:head>
<title><ui:insert name="title">Place holder for title</ui:insert>
</title>
</h:head>
<h:body>
</h:body>
</html>
Second template which is using MainTemplate.xhtml - Template1.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" template="MainTemplate.xhtml">
<ui:define name="body">
<h:outputScript library="script" name="processcript.js" target="head" />
<h:form id="baseForm">
</h:form>
*some layout is defined here*
</ui:define>
</ui:composition>
The page where above template is being used:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
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:pe="http://primefaces.org/ui/extensions"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<head></head>
<h:body>
<ui:composition template="/WEB-INF/templates/Template1.xhtml">
<ui:define name="title">
<h:outputText value="#{myBean.title}"></h:outputText>
</ui:define>
</ui:composition>
</h:body>
</html>