Friday, April 12, 2019

Re: How to get the SuggestBox value

Yes, or a full solution that I just tested it works:

 public void onModuleLoad()

    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    String[] words = {"Alpha", "Apple", "Anaconda", "Beta", "Beautiful", "Best", "Better"};
    for (String word: words)

    SuggestBox suggestBox = new SuggestBox(oracle);
    suggestBox.setSize("300px", "40px");

    suggestBox.addSelectionHandler((SelectionEvent<SuggestOracle.Suggestion> suggestion) ->
      GWT.log("SuggestBox Value: " + suggestBox.getValue());

      // You can also get the value this way from the event:
      GWT.log("Selected Value: " + suggestion.getSelectedItem().getReplacementString());

    DockLayoutPanel p = new DockLayoutPanel(Style.Unit.EM);

    RootLayoutPanel rp = RootLayoutPanel.get();

On Friday, April 12, 2019 at 3:42:09 PM UTC-6, Filipe Sousa wrote:

On Thursday, April 11, 2019 at 12:02:57 PM UTC+1, Nanditha Nandu wrote:
final SuggestBox  suggestionBox = new SuggestBox(suggestions);

where suggestions is the custom suggest words passed using MultiWordSuggestOracle

Im trying to get the value selected from the suggestions in the SuggestBox using below line:

 String text = suggestionBox.getTextBox().getValue();

But the value of text is " "

Please help.Thanks.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment