<p:ajax listener= "" is not invoking listener

UI Components for JSF
Post Reply
mhmdawwad123
Posts: 9
Joined: 28 Nov 2010, 14:44

29 Nov 2010, 01:49

Hello, i have a problem in <p:ajax listener which is it does not invoke the listener method in the backing bean, i am trying to run the example in the showcase
it's not working at all

the example is:

Code: Select all

<h:form>
			
	<p:ajaxStatus style="width:16px;height:16px;">
		<f:facet name="start">
			<h:graphicImage value="../design/ajaxloading.gif" />
		</f:facet>
		
		<f:facet name="complete">
			<h:outputText value="" />
		</f:facet>
	</p:ajaxStatus>

	<h:panelGrid columns="3">
		<h:outputText value="Keyup: " />
		
		<h:inputText id="counter">
			<p:ajax event="keyup" update="out" 
					listener="#{counterBean.increment}"/>
		</h:inputText>
		
		<h:outputText id="out" value="#{counterBean.count}" />
	</h:panelGrid>
	
</h:form>

Code: Select all

package org.primefaces.examples.view;

import java.io.Serializable;

public class CounterBean implements Serializable{

	private int count;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
	
	public void increment() {
		count++;
	}
}
i did everything required in the example steps but once i run the page and start typing in the inputtext ,, ajax does not call the srver side at all (does not invoke method increment() )

Primefaces is amazing and i am willing to start using it in my projects but i need to fix this bug to be able to continue
any help would be appreciated

thanks

callahan
Posts: 768
Joined: 27 May 2010, 22:52

29 Nov 2010, 02:18

Is CounterBean registered as a managedBean?

mhmdawwad123
Posts: 9
Joined: 28 Nov 2010, 14:44

29 Nov 2010, 09:01

Yes Sure ,, i tried all the possibilities i tried newest releases i am wondering if i works with you or anyone else would you please share me a sample code so i can try again ,,
and also what release do you recommend since i am using the newest one 2.2.RC2.

Advise please :)

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

29 Nov 2010, 10:19

Same showcase sample is working;

http://www.primefaces.org/showcase/ui/ajaxifyAction.jsf

Maybe you have an environment problem, showcase is using JSF mojarra 2.0.3 on tomcat 6. What is your env?

mhmdawwad123
Posts: 9
Joined: 28 Nov 2010, 14:44

29 Nov 2010, 10:27

Hello ,,,
please find below another try , the code is

testbean.java

Code: Select all

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author mawwad
 */
@ManagedBean
@RequestScoped
public class testBean implements Serializable{

    /** Creates a new instance of testBean */
    public testBean() {
    }


    private int count;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public void increment() {
		count++;
	}

}
index.xhtml

Code: Select all

<?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:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>

            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="../design/ajaxloading.gif" />
                </f:facet>

                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>

            <h:panelGrid columns="3">
                <h:outputText value="Keyup: " />

                <h:inputText id="counter">
                    <p:ajax event="keyup" update="out"
                            listener="#{testBean.increment}"/>
                </h:inputText>

                <h:outputText id="out" value="#{testBean.count}" />
            </h:panelGrid>

        </h:form>
    </h:body>
</html>

web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.allowTextChildren</param-name>
        <param-value>true</param-value>
    </context-param>
    <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>
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
note that i am using : apache tomcat 6.0.26 , netbeans 6.9, jsf 2.0 , primefaces 2.2-SNAPSHOT


I get the following exception on tomcat log :
javax.faces.FacesException: /index.xhtml @28,63 listener="#{testBean.increment}": java.lang.IllegalArgumentException: wrong number of arguments
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at java.lang.Thread.run(Thread.java:619)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.Thread.run(Thread.java:619)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Caused by: javax.el.ELException: /index.xhtml @28,63 listener="#{testBean.increment}": java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:104)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.primefaces.component.behavior.ajax.AjaxBehavior.broadcast(AjaxBehavior.java:193)
at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:763)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
... 23 more
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)

horrikhalid
Posts: 9
Joined: 10 Nov 2010, 19:18

29 Nov 2010, 12:21

Hi,
I have the same problem, and to solve it I use actionListener instead and it work perfectly.

I have a question to cagatay : is the <p:ajax inhert from f:ajax ? because Jim Driscoll in this post use AjaxBehaviorEvent with the listener

regards

mhmdawwad123
Posts: 9
Joined: 28 Nov 2010, 14:44

29 Nov 2010, 13:04

just got the solution ,,, DO NOT waste your time on <p:ajax there is no use it works ,, just use another effective super alternative which is <f:ajax ,,
as simple as that

rtc
Posts: 13
Joined: 05 Jan 2011, 10:52

05 Jan 2011, 13:19

söz konusu ajax sitedeki show case de çalışmakta fakat kendi projemizde bir türlü çalışmıyor sitede de bu konuda yeterli açıklama yok gibi.
net beans da proje tanımlamaları nasıl yapılacak bilemiyoruz. standart tanımların dışında bir şeylermi var acaba.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests