hello all
i was trying to implement the Ajax counter demo which presented at http://97.107.138.40:8080/prime-showcas ... ounter.jsf. now my web project can run properly, but the problem is when i click the button, the number does not increase....can anyone points me the error? thanks in advance.
the JARs i used
jsf-api.jar
jsf-impl.jar
jsf-facelets.jar
primefaces-ui-0.9.3.jar
optimus-0.8.0.jar
slf-4j-api-1.5.8.jar
slf-4j-impl-1.5.8.jar
log4j-1.2.15.jar
guice-2.0.jar
the xhtml file
<?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" xml:lang="en" lang="en"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>hello</title>
<p:resources />
</head>
<f:view>
<body>
<h:form>
<h:outputText id="txt_count" value="#{counterBean.count}" />
<p:commandButton value="Count"
actionListener="#{counterBean.increment}" async="true"
update="txt_count" />
</h:form>
</body>
</f:view>
</html>
the java file
import java.io.Serializable;
import javax.faces.event.ActionEvent;
import org.primefaces.optimus.config.Scope;
import org.primefaces.optimus.config.annotations.Controller;
@SuppressWarnings("serial")
@Controller(name="counterBean", scope=Scope.VIEW)
public class CountBean implements Serializable {
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void increment(ActionEvent actionEvent) {
count++;
}
}
the web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- primeFaces configuration -->
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.ui.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resources/*</url-pattern>
</servlet-mapping>
<!-- primeFaces configuration ended -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>optimus.CONTEXT_SCAN_PATH</param-name>
<param-value>com.vub.bean</param-value>
</context-param>
<!-- added by Hao -->
<mime-mapping>
<extension>xhtml</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
ajax counter
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
<h:form prependId="false"> should fix it
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
You are welcome.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 27 guests