I'm unable to pass a simple parameter from one Facelet to another, and set a bean property...here's my code:
The calling page, main.xhtml (only relevant code):
<h:link outcome="index" value="disconnect" >
<f:param name="logout" value="true" />
</h:link>
The final page, index.xhtml:
<?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:f="http://xmlns.jcp.org/jsf/core">
<f:metadata>
<f:viewParam name="logout" value="#{indexBean.logout}"/>
<f:event type="preRenderView" listener="#{indexBean.redirect}" />
</f:metadata>
</html>
And the IndexBean (only relevant code):
@Named
@RequestScoped
public class IndexBean {
@Inject
private Logger logger;
private boolean logout;
public IndexBean() {this.logout = false;}
public void setLogout(boolean logout) {
logger.log(Level.DEBUG, "logout changed");
this.logout = logout;
}
public boolean isLogout() {return logout;}
public void redirect() throws IOException {
if(logout) {
//Never get in here
} else {
//Always here
}
}
}
I'm getting the URL parameter right on the link (http://localhost/index.xhtml?logout=true), but the setLogout
method is never called.
I've even tried to change the logout
type to String, change getter and setter properly and see what happens, but the setter is never called...
Any idea?
Thanks in advance!!