I make liberal use of suggestionboxes in my app. For example:
<h:inputText id="it30" value="#{devices.name}"
onkeypress="#{rich:component('s30')}.callSuggestion(true)" />
<rich:suggestionbox id="s30"
suggestionAction="#{deviceNameList.suggest}" var="_dev" for="it30"
nothingLabel="Device not found">
<h:column>
<h:outputText value="#{_dev}" id="ot3" />
</h:column>
</rich:suggestionbox>
Here is the code backing up the suggestionAction:
public class DeviceNameList extends EntityQuery<String> {
List<String> devList = new ArrayList<String>();
@Override
public String getEjbql() {
// TODO Auto-generated method stub
return "select d.name from Devices d order by d.name";
}
public DeviceNameList() {
this.devList = getEntityManager().createQuery(this.getEjbql()).getResultList();
}
public List<String> suggest(Object input
if (input==null) {
return returnDevices;
}
String searchString = (String) input;
List<String> returnDevices = new ArrayList<String>();
Iterator<String> iterator = devList.iterator();
while (iterator.hasNext()) {
String element = (String) iterator.next();
if (element.toLowerCase().contains(searchString.toLowerCase())) {
returnDevices.add(element);
}
}
return returnDevices;
}
}
But I find the response time to be quite sluggish, though not all the time. In this case my potential list of suggestions has over 6,000 elements in it. Is this simply too much? I feel the same sluggishness with a suggestion list of only 50 hard-coded state names (AK, AL, etc). I'm ready to release this to beta-testers,but I still feel the suggestionbox is performing as it should.
Any suggestions?
TDR