title: Retrieving current user entered value from GWT SuggestBox
body: <p>I'm new to GWT. I have a simple <em>SuggestBox</em> which is populated using a <em>MultiWordSuggestOracle</em>. Users input their data to this SuggestBox, and if they find any match with the existing Suggestions its well and good. I'm able to retrieve this value in the SelectionHandler code as below.</p>
  
  <pre><code>    display.getSuggestBox().addSelectionHandler(new SelectionHandler&lt;Suggestion&gt;() {
  
          public void onSelection(SelectionEvent&lt;Suggestion&gt; event) {
  
              String selectedProperty =   ((SuggestBox)event.getSource()).getValue();
              // do something with the property value
          }
      });
  </code></pre>
  
  <p>But users are allowed to enter values which are not already in the Suggestion oracle, in which case I should read this value and do something with this,may be saving to db as a new data.(The thing which I'm looking for is something like a browsers navigation widget where we show suggestions, users can pick up any suggestion or he can type in his new entry and carry on.) What I needed is a way to retrieve this new text user has entered? Data will be read on a button click. What I tried out is this.</p>
  
  <pre><code>    display.getSaveBtn().addClickHandler(new ClickHandler() {
  
          public void onClick(ClickEvent event) {
  
  
                  String selectedProperty = display.getSuggestBox().getValue();
                  //String selectedProperty2 = display.getSuggestBox().getText();
  
      // Blank in both cases :(
      // tried display.getSuggestBox().getTextBox().getValue(),but blank again
  
          }
  
      });
  </code></pre>
  
  <p>I tried to employ onChange() event handlers (as shown below) </p>
  
  <pre><code>    display.getSuggestBox().addValueChangeHandler(new ValueChangeHandler&lt;String&gt;() {
  
          public void onValueChange(ValueChangeEvent&lt;String&gt; event) {
              String selectedProperty = ((SuggestBox)event.getSource()).getValue();
              Window.alert("on change -- "+selectedProperty);
  
          }
      });
  </code></pre>
  
  <p>This is working fine except one scenario. Suppose there are two suggestions in the oracle,say 'createTicketWsdl' and 'createTicketTimeout'. When the user types in <strong>'cr'</strong>, he is opted with these two options, and if he selects 'createTicketWsdl' <strong>by pressing keyboard ENTER</strong>, then my alert is printing 'createTicketWsdl' which is correct. But if he selects 'createTicketWsdl' <strong>using mouse</strong>, then my alert is printing <strong>'cr'</strong> (I tried to post the screenshot to give a better understanding, but being a new user I'm not allowed).(which I wanted to get as 'createTicketWsdl'since thats what he has selected). Soon after printing my alert, the value in the SuggestBox changes to 'createTicketWsdl'.</p>
  
  <p>Is there a way to retrieve the value of the suggest box? I saw a similiar thread <a href="https://stackoverflow.com/questions/4475277/gwt-suggestbox-listbox-widget">GWT SuggestBox + ListBox Widget</a>, where some source code for a custom widget is available. But I didn't take the pain of trying out that, since what I want is simply get the current value from the SuggestBox and I hope there should be some easy way.</p>
  
  <p>Thanks for all your help!</p>