I have a JSF template which dynamically includes the content to be displayed after the user had selected it through the menu:
<ui:composition 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"
template="/WEB-INF/templates/template.xhtml">
<ui:define name="main">
<p:panel id="content">
<ui:include src="#{navigationMb.page}" />
</p:panel>
</ui:define>
</ui:composition>
One of the pages I'd like to include has a p:commandButton as follows:
<ui:composition 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">
<div class="ui-fluid">
<h:form>
<p:panelGrid
id="changePasswordPanel"
layout="grid"
columns="2"
styleClass="ui-panelgrid-blank">
...
<p:commandButton value="Change Password"
action="#{changePasswordMb.changePassword}"
update="changePasswordPanel"
icon="ui-icon-check" />
</p:panelGrid>
</h:form>
</div>
</ui:composition>
Which was supposed to call the following method in my backing bean:
package com.bgasparotto.archproject.web.security;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
@Named
@RequestScoped
public class ChangePasswordMb {
@Inject
private Logger logger;
public void changePassword() {
logger.info("TESTE");
}
}
However, my changePassword
method is never called.
Moreover, if I simply put the content of my included page directly into my main page, it works:
<ui:composition 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"
template="/WEB-INF/templates/template.xhtml">
<ui:define name="main">
<p:panel id="content">
<div class="ui-fluid">
<h:form>
<p:panelGrid
id="changePasswordPanel"
layout="grid"
columns="2"
styleClass="ui-panelgrid-blank">
...
<p:commandButton value="Change Password"
action="#{changePasswordMb.changePassword}"
update="changePasswordPanel"
icon="ui-icon-check" />
</p:panelGrid>
</h:form>
</div>
</p:panel>
</ui:define>
</ui:composition>
Digging around StackOverflow, I've found this great guide by BalusC to debug my application. I've checked every possible cause but it didn't work.
Also, I've tried including OmniFaces fixviewstate.js
in my template but it also didn't work:
<h:body>
<h:outputScript library="omnifaces" name="fixviewstate.js" target="head" />
...
<h:body>
EDIT 1
Here is the code for my NavigationMb
:
package com.bgasparotto.archproject.web;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
@Named
@RequestScoped
public class NavigationMb {
private String page;
public NavigationMb() {
this("welcome.xhtml");
}
public NavigationMb(String page) {
this.page = page;
}
public void nav(String page) {
this.page = page;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
}
I've ran out of possible solutions. Any ideas?
My setup:
- Java 8
- Wildfly 10.1.0.Final (Java EE 7)
- (JSF 2.2, Mojarra 2.2.13 SP1)
- Primefaces 6.1
- OmniFaces 2.6.4
- CDI with Weld 2.3.5
Thanks in advance.