On 03/15/10 02:42, Ben Hutchison wrote:
Hi all,
We're developing a wicket web-application that makes heavy use of
auto-complete text fields populated from slow back-end (mainframe) web
services.
Concerned that standard auto-complete behavior will be too chatty and
result in many calls to slow services, we're keen on an alternative less
chatty model:
- No autocomplete behavior is triggered until at least N (eg 3)
characters have been entered.
- When N characters are entered, a query is performed, once.
- These results are cached client-side, and subsequent character entry
simply narrows the search in the pre-retrieved results.
- If any of the first N characters in the string are altered, the cache
results are discarded and a new query is performed.
All this should be doable with reasonable effort by overriding
AutoCompleteTextField's getChoices(). I've never stored things
client-side, but I'm sure you can find how to do that in the archives or
the wiki. Apart from that, you would do something like that:
String prevInput;
List<String> suggestions;
@Override
protected Iterator<String> getChoices(String input)
{
if (!suggestions.isEmpty() && firstNEqual(input, prevInput)
// narrow down existing suggestions
else if (input.length() >= MIN_INPUT_LENGTH)
// backend service query, filling suggestions
else
return Collections.<String>emptyList().iterator();
}
--
-------------------------------------------------------------------
Thomas Kappler thomas.kapp...@isb-sib.ch
Swiss Institute of Bioinformatics Tel: +41 22 379 51 89
CMU, rue Michel Servet 1
1211 Geneve 4
Switzerland http://www.uniprot.org
-------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org