0

I have this xhtml:

<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>Test</title>
</h:head>
<h:body>
    <h:form>
        <h:inputText id="userId" 
                     value="#{user.id}" 
                     valueChangeListener="#{user.changeId}"/>
    </h:form>
</h:body>
</html>

And this bean:

@ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable {

    private String id;

    public String getId() { return id;}

    public void setId(String id) { this.id = id;}

    public void changeId(ValueChangeEvent event) {
        id = (String) event.getNewValue(); 
    }

}

I want that value of field id in my bean will change after I've written in inputText, but valueChangeListener doesn't work. Where the problem is ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Your problem is unclear. How exactly are you invoking it? We don't see the trigger anywhere in your code. Or is that actually your actual problem, that you actually have no idea what's the correct way to invoke it? This problem is only quite different from your described "doesn't work" problem which implies that it was successfully invoked (as confirmed by the debugger) but just didn't run. – BalusC Dec 20 '17 at 10:20
  • @balusc, I thought, valueChangeListener="#{user.changeId}" would be enough. Listener didn't run, so, yes, i don't have any idea what's the correct way to invoke it. I just want to autosave value in my bean. – Igor Mikhin Dec 20 '17 at 10:41

0 Answers0