just a question....don't know if I did it right or if this will not work by specs. I've made a simple facelets master template, like this:
template.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<ui:insert name="metadata" />
<h:head>
.... here the rest of template with other <ui:insert>
The client is simple and uses the template:
main.xhtml
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
template="./WEB-INF/template/template.xhtml">
<ui:define name="metadata">
<ui:include src="./WEB-INF/template/securityCheck.xhtml" />
</ui:define>
... here goes the rest with other <ui:define> and <ui:include> ....
In the securityCheck.xhtml lies the simple f:viewAction
as follow:
securityCheck.xhtml
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:metadata>
<f:viewAction action="#{loginController.doLoginCheck()}" />
</f:metadata>
</ui:composition>
Well, in this cas the f:viewAction is not ivoked, instead if I expand into metadata section the code directly, as follow:
main.xhtml
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
template="./WEB-INF/template/template.xhtml">
<ui:define name="metadata">
<f:metadata>
<f:viewAction action="#{loginController.doLoginCheck()}" />
</f:metadata>
</ui:define>
... here goes the rest with other <ui:define> and <ui:include> ....
it works like a charm (as expected). Why is the inclusion of the metadata section into template client not working? And if there is a correct way to do this how can I add other f:viewAction calls after the included one? Something like this:
otherpage.xhtml
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
template="./WEB-INF/template/template.xhtml">
<ui:define name="metadata">
<ui:include src="./WEB-INF/template/securityCheck.xhtml" />
<f:metadata>
<f:viewAction action="#{myBean.doSomething()}" />
</f:metadata>
</ui:define>
... here goes the rest with other <ui:define> and <ui:include> ....
If this is correct, are the calls made in this specific order?
I'm using JavaEE 7/JSF 2.2 with Glassfish 4.1 and Mojarra 2.2.12 impl.
Thank you.