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. !!!!
AutoComplete selectListener() method is not invoking
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..!!!!
<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..!!!!
Have a look here: http://cagataycivici.wordpress.com/2011 ... behaviors/
I guess the selectListener is not used anymore.
try:
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>
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..
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..
-
- Information
-
Who is online
Users browsing this forum: No registered users and 28 guests