Search code examples
jsongwtlistboxsuggestbox

Merge ListBox & SuggestionBox


I have a ListBox in GWT which having the list of data which comes after the Parsing of JSON.

//ListBox test
private ListBox test;
test = new ListBox();

After Parsing the JSON data I am adding the data to the ListBox test.

JSONObject  userObj = val.isObject(); 
JSONArray userArray = JSONUtil.getJSONArray(userObj, "objects");
for (int i = 0; i < userArray.size(); i++) {
   JSONObject childJSONObject = (JSONObject) userArray.get(i);
   String userName = JSONUtil.getStringValue(childJSONObject, "name"); 
   test.addItem(userName);
 }

This works fine for Me. I want to merge it with SuggestionBox, same as like Browsers Navigation widget. How can i implement this ?

Thanks.


Solution

  • I'm going to assume you mean SuggestBox instead of SuggestionBox...

    That said, if you want a ListBox that allows a user to type into it to select an entry, take a look at GwtChosen.

    It seems to have been created for this exact use case. You need a ChosenListBox:

    ChosenListBox

    Code samples and documentation here: http://jdramaix.github.io/gwtchosen/