I have defined a layout template to use with my jsf client page. It mostly works ok except that the metadata event defined above the head section no longer fires. This event preloads data from a database. The client code is as follows:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:event type="preRenderView" listener="#{orderFormBean.loadPricelistProducts}" />
</f:metadata>
<h:head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coop Order Form</title>
<h:outputStylesheet library="css" name="style.css" />
</h:head>
<h:body>
<ui:composition template="/memberTemplate.xhtml">
<ui:define name="pageContent">
This is followed by the body of the form (too lengthy to include here, seems to be working ok). After the page contents, the client code ends with:
</ui:define>
</ui:composition>
</h:body>
</html>
Content-wise this is working ok, but how do I get it to incorporate the metadata event which is outside of the body of the page?
My template code is as follows:
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Welcome</title>
<style>
.ui-layout-unit .ui-layout-unit-content {
padding: 0.2em 0em;
border: 0px none;
overflow: hidden !important;
}
</style>
</h:head>
<h:body>
<p:layout style="margin: 0px; gutter: 0px !important!" fullPage="false" >
<p:layoutUnit position="north" size="100" resizable="false" closable="false" collapsible="true" gutter="0" >
<img src="#{request.contextPath}/resources/images/SimplyWaiheke3.jpg" />
</p:layoutUnit>
<p:layoutUnit position="west" size="210" resizable="false" closable="false" collapsible="false" gutter="0">
<h:form id="menuForm">
<p:menu style="width:180px">
<p:menuitem value="Current order" url="/OrderForm2.xhtml" icon="ui-icon-home" rendered="#{loginBean.hasRole('Buyer')}" />
<p:menuitem value="Previous orders" url="AdminUsers.xhtml" icon="ui-icon-home" rendered="#{loginBean.hasRole('Buyer')}" />
<p:menuitem value="My account" url="AdminUsers.xhtml" icon="ui-icon-document" rendered="#{loginBean.hasRole('Member')}" />
<p:menuitem value="Edit profile" url="AdminUsers.xhtml" icon="ui-icon-arrowthick-1-s" rendered="#{loginBean.hasRole('Buyer')}" />
<p:menuitem value="Ordering" url="AdminUsers.xhtml" icon="ui-icon-wrench" rendered="#{loginBean.hasRole('Ordering')}" />
<p:menuitem value="Shareout" url="AdminUsers.xhtml" icon="ui-icon-wrench" rendered="#{loginBean.hasRole('Shareout')}" />
<p:menuitem value="Accounts" url="AdminUsers.xhtml" icon="ui-icon-wrench" rendered="#{loginBean.hasRole('Accounts')}" />
<p:menuitem value="Admin" url="AdminUsers.xhtml" icon="ui-icon-wrench" rendered="#{loginBean.hasRole('Admin')}" />
<p:menuitem value="Sign out" action="#{loginBean.doLogout}" icon="ui-icon-wrench" />
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center" collapsible="true" gutter="0">
<ui:insert name="pageContent" >
This is the default page content
</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>