1

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!!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Alex
  • 327
  • 1
  • 3
  • 12
  • Which JSF impl/version? Anything in server logs? Any messages when you add ``? – BalusC Mar 12 '15 at 14:56
  • possible duplicate of [Using new xmlns.jcp.org namespace on composites causes java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.putIfAbsent](http://stackoverflow.com/questions/18436511/using-new-xmlns-jcp-org-namespace-on-composites-causes-java-lang-nullpointerexce) – Bjørn-Roger Kringsjå Mar 13 '15 at 19:27

0 Answers0