I can't reproduce this on Mojarra 2.0.2 ~ 2.0.6 and 2.1.1. I used the following test bean
@ManagedBean
@RequestScoped
public class Bean {
private String title = "default";
public void preRenderView(ComponentSystemEvent event) {
title = "newtitle";
}
public String getTitle() {
return title;
}
}
And the following view:
<!DOCTYPE html>
<html lang="en"
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"
>
<f:event type="preRenderView" listener="#{bean.preRenderView}" />
<h:head>
<title>#{bean.title}</title>
</h:head>
<h:body>
<h1>Peek-a-boo</h1>
</h:body>
</html>
And also the following master template
<!DOCTYPE html>
<html lang="en"
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"
>
<f:event type="preRenderView" listener="#{bean.preRenderView}" />
<h:head>
<title><ui:insert name="title">Default title</ui:insert></title>
</h:head>
<h:body>
<ui:insert name="content">Default content</ui:insert>
</h:body>
</html>
with this definition
<ui:composition template="/template.xhtml"
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"
>
<ui:define name="title">
#{bean.title}
</ui:define>
<ui:define name="content">
<h1>Peek-a-boo</h1>
</ui:define>
</ui:composition>
All works equally fine. The title becomes newtitle
in all cases. It also didn't really matter where the <f:event>
was placed in the template. Before head, inside body, in the master template or in the template definition.
Probably the problem is in the way how you invoked preRenderView
. The above examples should give you a good kickoff to build further on and to naildown your actual problen.