-
1. Re: Autocomplete component not handling items with spaces correctly
sunkaram Feb 23, 2012 12:31 PM (in response to joeferraro)its not the component problem, Its depends on the way you implement your bean method to return list of suggested values based on user entered characters..
-
2. Re: Autocomplete component not handling items with spaces correctly
joeferraro Mar 13, 2012 5:23 PM (in response to sunkaram)Thanks for the response but I don't think it is a back bean issue. I've made a very simple case to try to illustrate the problem taht is found when using IE 8.
Here is a simple back bean that supplies a list to the autocomplete field and stores the returned value.
import java.util.ArrayList;
import java.util.List;
public class GeneSearchBean {
private String[] values = {"ball", "bat", "cat", "car", "dog", "donkey", "elephant", "frog", "fossil", "fire", "pony", "piano"};
private List<String> listValues = new ArrayList<String>();
private String searchTerm;
public String getSearchTerm() {
return searchTerm;
}
public void setSearchTerm(String searchTerm) {
this.searchTerm = searchTerm;
}
public List<String> suggest(Object input) {
String prefix = (String)input;
List<String> listValues = new ArrayList<String>();
for (String value: values) {
if(value.startsWith(prefix)) {
listValues.add(value);
}
}
return listValues;
}
public List<String> getListValues() {
return listValues;
}
public void setListValues(List<String> listValues) {
this.listValues = listValues;
}
}
I then created the following autocomplete field within a form:
<rich:autocomplete value="#{geneSearchBean.searchTerm}" mode="ajax" tokens=", "
minChars="2" autofill="false" autocompleteMethod="#{geneSearchBean.suggest}" />
If I enter ba into the field I see the list of ba items. I can down arrow to an item and press return to select it. (bat) I can then hit space and press ca and see two items. Again if I down arrow and press return everything appears to work correctly, I have displayed ( bat cat). Finally if I again press ca and use the mouse to select an item, the first item gets replaced. What I am left seeing is car cat ca. it appears the selection with a mouse is being handled differently.
I have breaks set on the back bean and the only method that gets called is the suggest method so I don't see how it can be a back bean issue.
Is anyone else seeing this problem or have a solution for it?