Search code examples
gwtsuggestbox

how to enforce selection from the suggestBox list in gwt


Hie

We are using a gwt SuggestBox which shows suggestions as user starts typing into this box. however, there is a possibility that end user just type something and do not select anything from the list.

we want to avoid this use case and display error if user do not select anything from the list.

any advise on how can we implement this? The real issue is how to get the list of current suggestions which are display? i dont see any method in suggestOracle class to get the list?

So, anyway without firing another query to get the current list of displayed suggestions?


Solution

  • Listen to the ValueChangeEvent of the underlying TextBox and check if the value matches any of the selectable values (you can make a call to the SuggestOracle and display an error if it returns zero or more than 1 results; if it returns a single result, you might want to check whether the values are equal).