I'm having trouble with a JSF test application and PrimeFaces components, and can't find the error.
I started out with a template file (layoutTempl.xhtml) defined by:
....
<h:body>
<p:layout fullPage="true" >
<p:layoutUnit position="north" size="95" >
<ui:insert name="menubar" >
MenuBar
</ui:insert>
</p:layoutUnit>
<p:layoutUnit position="west" resizable="false" size="250">
<ui:insert name="tree" >
ProjectTree
</ui:insert>
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="main" >
MainContent
</ui:insert>
</p:layoutUnit>
<p:layoutUnit position="south" size="45">
<ui:insert name="footer" >
Footer
</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
....
This template is used in two pages (indexContent.xhtml):
....
<body>
<ui:composition template="./layoutTempl.xhtml">
<ui:define name="menubar">
MenuBar
</ui:define>
<ui:define name="tree">
Project Tree
</ui:define>
<ui:define name="main">
<ui:include src="index.xhtml"/>
</ui:define>
<ui:define name="footer">
Footer
</ui:define>
</ui:composition>
</body>
....
and (abcContent.xhtml):
....
<body>
<ui:composition template="./layoutTempl.xhtml">
<ui:define name="menubar">
MenuBar
</ui:define>
<ui:define name="tree">
Project Tree
</ui:define>
<ui:define name="main">
<ui:include src="abc.xhtml"/>
</ui:define>
<ui:define name="footer">
Footer
</ui:define>
</ui:composition>
</body>
....
The included files index.xhtml contain:
....
<h:body>
<ui:composition >
Hello from BareTest
<br /><br />
<h:form id="myform">
<p:selectOneMenu id="scroll2"
value="#{listTestBean.selectedMyObject}" >
<f:selectItems value="#{listTestBean.myObjects}"/>
<p:ajax event="change" listener="#{listTestBean.valueChanged}"/>
</p:selectOneMenu>
<br/><br/>
</h:form>
</ui:composition>
</h:body>
....
while abc.xhtml contains:
....
<h:body>
<h2>We got at abc page!</h2>
<br /><br />
<h:form id="abcForm">
<p>#{listTestBean.selectedMyObject}</p>
<p:commandLink id="Ajax" ajax="true" action="indexContent?faces-redirect=false">
<h:outputText value="Main page (link)" />
</p:commandLink>
</h:form>
</h:body>
....
The request scoped managed bean listTestBean contains getter and setter methods and the valueChanged method. The valueChanged method holds:
....
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("abcContent.xhtml");
} catch (IOException ioe) {
System.err.println("listTestBean.valueChanged: IOException");
}
....
which is basically a redirect to the abcContent page.
However, when I select an item from the selectItem component the abcContent.xhtml page is not rendered, with the specified layoutTempl?
That I don't understand at all, sorry! It's probably something trivial but I can't solve it!
Regards