I´m new working with JSF, so I am sure that this is really stupid question but I couldn't find any post that help me. I´m using ajax poll in my project because I need refresh components in the page. I founded an example in the primefaces 5 showcase. In this example there is a counter that increments every 3 seconds. I used the code of the example in the exactly same way but the counter never increments. I think that this could be a bad configuration that I used in my project. Also, its showed the next message in the Eclipse console (I don´t know if this has something to do with my problem):
Code: Select all
Información: No state saving method defined, assuming default server state saving
Code: Select all
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>
<title>Insert title here</title>
</h:head>
<h:body>
<h:form>
<h:outputText id="txt_count" value="#{globalCounterView.count}"/>
<p:poll interval="3" listener="#{globalCounterView.increment}" update="txt_count"/>
</h:form>
</h:body>
</html>
Code: Select all
import java.io.Serializable;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.event.ActionEvent;
@ManagedBean
@ApplicationScoped
public class GlobalCounterView implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private int count;
public int getCount() {
return count;
}
public void increment(ActionEvent actionEvent) {
count++;
}
public void setCount(int count) {
this.count = count;
}
}
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SAEGraph</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
In the end, the thing what I want to do is update a primeface component from backing bean periodically. Also, Can you tell me if exists any other way to do this not using poll ????
Thanks and sorry again for the bad english.
I'm using primefaces 5.0, Tomcat 7, Eclipse Version: 4, JDK 7