webtier@glassfish.java.net

Re: bug at jsf 2.0 f:setPropertyActionListener

From: <webtier_at_javadesktop.org>
Date: Tue, 09 Mar 2010 00:09:47 PST

It's simple test which I tried to undestand this problem. What message should appear when click on test button? I think there should be "heyMan", but if you'll try you see "heynull" at first click. And only after second click you'll see right message

@ManagedBean(name="testBean")
@SessionScoped
public class TestBean implements Serializable{
    private String name;
    private String message;

    public void test(ActionEvent e) {
        message = "hey" + name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
        <h:commandButton actionListener="#{testBean.test}" value="test">
            <f:setPropertyActionListener target="#{testBean.name}" value="Man"/>
        </h:commandButton>

        <h:outputText value="#{testBean.message}"/>
        </h:form>
    </h:body>
</html>
[Message sent by forum member 'neverminddenis' (zhupinskij_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=390815