简体   繁体   中英

Suggestbox returning suggestions that begin AND contain the user's input

I am using a SuggestBox and I am having some difficulties to obtain the good behavior of my application.

Consider the following list of suggestions :

1. lol 
2. good evening
3. goodbye
4. end 
5. saluti

If I use my SuggestBox with this list and I type "g" I will obtain :

1. good evening
2. goodbye

It I type "e" :

1. good evening
2. end

But what I want to obtain is the words containing the input and not only the ones beginning with the input. For example if I type "l", I want to obtain :

1. lol
2. saluti

and not only :

1. lol

How can I fix this?

Thank you for your help.

The SuggestBox is using a SuggestOracle to decide what to return given some input. The default oracle for a SuggestBox is MultiWordSuggestOracle that has the behaviour you describe. If you want some other behaviour, you will have to write your own oracle by extending SuggestOracle. Check out this very good blog tutorial on how to implement autocompletion in GWT.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM