I have a typical structure and menu page with JSF templates. Below is the code for my homepage.
<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:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="/templates/internal3section.xhtml">
<ui:define name="events">
<f:event listener="#{mainBean.entryGate}" type="preRenderView" />
</ui:define>
<ui:define name="headerarea">
<p:panel style="margin:10px;">
<h:outputText value="WelCome "></h:outputText><br/>
<h:outputText value="You are using the application to view data for"></h:outputText><br/>
<p:selectOneMenu value="#{mainBean.selectedId}">
<p:ajax update=":extPane:content" />
<f:selectItems value="#{mainBean.ids}" var="id"
itemLabel="#{id.name}
itemValue="#{id.entityId}"/>
</p:selectOneMenu>
</p:panel>
</ui:define>
<ui:define name="contents">
<h:form id="extPane">
<div>
<p:menubar style="margin-bottom:5px;">
<p:menuitem value="Schedule" icon="ui-icon-star" ajax="true"
actionListener="#{mainBean.setSelectedPage('schedule')}"
update="content">
</p:menuitem>
<p:menuitem value="Assignments" icon="ui-icon-star" ajax="true"
actionListener="#{mainBean.setSelectedPage('Assignments')}"
update="content">
</p:menuitem>
<p:menuitem value="Write to Us" icon="ui-icon-star" ajax="true"
actionListener="#{mainBean.setSelectedPage('writetous')}"
update="content">
</p:menuitem>
</p:menubar>
</div>
<div>
<p:panel>
<p:outputPanel id="content" layout="block" autoupdate="true" style="border-style: none; padding: 0;">
<c:if test="#{mainBean.selectedPage!=null}">
<ui:include src="external/#{mainBean.selectedPage}.xhtml" />
</c:if>
</p:outputPanel>
</p:panel>
</div>
</h:form>
</ui:define>
I have two types of menus: one that changes the type of report, and another that changes the report data (based on the identifier of the object).
My included pages have a preRenderEvent to keep track of updates based on changes to the entityId using the top selectOneMenu.
Here is the code for one of my include 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:em="http://java.sun.com/jsf/composite/emcomp"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:event listener="#{noteBean.loadRequests}" type="preRenderView" />
<h:head>
</h:head>
<h:body>
<div>
<p:panel header="Send a New Note for #{mainBean.selectedEntity.name}" id="notePanel" toggleable="TRUE" collapsed="FALSE" >
...
</p:panel>
</div>
</h:body>
My problem is that the preRenderView event in the included files does not fire. They do not start even the first time the page is displayed.
I'm not sure if this is due to the fact that ui: include happens through an ajax request. I assume page load events do not fire when ajax is updated.
actionEvent , . , - preRenderView .
,
- - , preRenderView ui: include.
- ?