AutoComplete selectListener() method is not invoking

UI Components for JSF
Post Reply
snayak
Posts: 31
Joined: 24 Jan 2011, 14:18

14 Jul 2011, 15:25

Hi All,

I'm using Primefaces 3.0.M3-SNAPSHOT with jsf

I have autocomplete field in xhtml, for which selectListener is not invoking the method,

<p:autoComplete id="autoTest"
completeMethod="#{testAutoComplete.complete}"
selectListener="#{testAutoComplete.handleSelect}"
onSelectUpdate="autoName"/>

completeMethod="#{testAutoComplete.complete}" complete method is getting called and I'm getting the list of suggestions.

After selecting the item, The selectListener="#{testAutoComplete.handleSelect}" is not invoking the handleSelect method.

Can anyone help me how to invoke selectListener method.

Thanks in advance. !!!!

snayak
Posts: 31
Joined: 24 Jan 2011, 14:18

14 Jul 2011, 15:28

I have the following code,

<h:form prependId="false">

<h:panelGrid columns="2" id="testPanelGrid">

<h:outputLabel value="Test"/>
<p:autoComplete id="autoTest"
completeMethod="#{testAutoComplete.complete}"
selectListener="#{testAutoComplete.handleSelect}"
onSelectUpdate="autoName"/>

<h:outputLabel value="name" />
<p:autoComplete id="autoName"
completeMethod="#{testAutoComplete.completeName}"
selectListener="#{testAutoComplete.handleSelectName}"
onSelectUpdate="city"/>

<h:outputLabel value="city" for="city" />
<p:inputText id="city" maxlength="80" />


</h:panelGrid>
</h:form>


public class TestAutoComplete
{

public TestAutoComplete()
{
super();
}

public List<String> complete(String query)
{
List<String> results = new ArrayList<String>();
for(int i = 0; i < 5; i++)
{
results.add(query + i);
}
return results;
}

public void handleSelect(SelectEvent event)
{
Object item = event.getObject();
InputText autoCompleteText = (InputText)FacesContext.getCurrentInstance().getViewRoot()
.findComponent("autoName");
autoCompleteText.setValue((String)item);
}

.
.
.
}


On Selecting item from suggestions, handleSelect(SelectEvent event) is not called.

Please anyone help how to solve this problem.

Thanks in advance..!!!!

robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

14 Jul 2011, 19:30

Have a look here: http://cagataycivici.wordpress.com/2011 ... behaviors/

I guess the selectListener is not used anymore.

try:

Code: Select all

<p:autoComplete id="autoTest" ......>
<p:ajax event="select" listener="#{testAutoComplete.handleSelect}" update="autoName" />
</p:autoComplete>

snayak
Posts: 31
Joined: 24 Jan 2011, 14:18

15 Jul 2011, 06:41

Hi robert, thank you for the solution :-)

I have gone through http://cagataycivici.wordpress.com/2011 ... behaviors/ and as u suugested i used
<p:ajax listener="#{testAutoComplete.handleSelect}" event="itemSelect" update="autoName"
process="@this" />

Is working fine. thank you very much for the help.. :-)

rkrenn
Posts: 33
Joined: 26 Jul 2011, 03:55
Location: Austria

24 Sep 2011, 18:00

this is the way to go, thanks!
Mojarra 2.1.28, PrimeFaces 3.3.1, Primefaces Extensions 0.7.0, libservlet3.1-java tomcat8, openjdk-8-jdk

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests