Problem using ajax listener

UI Components for JSF
Post Reply
priyanka
Posts: 48
Joined: 15 Feb 2012, 11:59

17 Feb 2012, 08:09

Sir i am using the same code which is there on site like

Code: Select all

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

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++;
	}
}
but sir i am facing a problem like every time i am pressing a key method gets called but value of count is reintialised to 0 only therefore it is showing 1 value even if i am pressing key several times.
Thank You
Primefaces version:3.1.RC1
JSf2.0
primefaces-extensions
IDE Eclipse Helios
Apache TomCat 6

User avatar
T.dot
Expert Member
Posts: 620
Joined: 01 Feb 2012, 15:39
Location: Vienna/Austria

17 Feb 2012, 08:53

What scope are you using for your managed bean? Use view scope!

priyanka
Posts: 48
Joined: 15 Feb 2012, 11:59

17 Feb 2012, 09:07

Thank You sir...
it works....
Primefaces version:3.1.RC1
JSf2.0
primefaces-extensions
IDE Eclipse Helios
Apache TomCat 6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 70 guests