I am beginning to code in JSF and PrimeFaces 6.1.
My index.xhtml looks like:
<?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://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<h:body>
<h:inputText id="counter">
<p:ajax update="out" listener="#{counterBean.increment}" />
</h:inputText>
<h:outputText id="out" value="#{counterBean.count}" />
</h:body>
</html>
And the CounterBean.java is:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class CounterBean implements Serializable {
private int count = 0;
public void increment() {
count++;
}
public int getCount() {
return count;
}
public void setCount(int name) {
this.count = name;
}
}
And even though I see the widgets for inputText and outputText are displayed, there is no ajax call made when the value of inputText changes. Similarly, the value of outputText does not change too when inputText changes.
What is wrong in the above code?