A
SuggestBox is a text box or text area which displays a
pre-configured set of selections that match the user's input.
Each
SuggestBox is associated with a single
SuggestOracle .
The
SuggestOracle is used to provide a set of selections given a
specific query string.
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
oracle.add("Cat");
oracle.add("Dog");
oracle.add("Horse");
oracle.add("Canary");
SuggestBox box = new SuggestBox(oracle);
Using the example above, if the user types "C" into the text widget, the
oracle will configure the suggestions with the "Cat" and "Canary"
suggestions. Specifically, whenever the user types a key into the text
widget, the value is submitted to the MultiWordSuggestOracle.
Note that there is no method to retrieve the "currently selected suggestion"
in a SuggestBox, because there are points in time where the currently
selected suggestion is not defined. For example, if the user types in some
text that does not match any of the SuggestBox's suggestions, then the
SuggestBox will not have a currently selected suggestion. It is more useful
to know when a suggestion has been chosen from the SuggestBox's list of
suggestions. A SuggestBox fires
SuggestionEvent SuggestionEvents whenever a suggestion is chosen, and
handlers for these events can be added using the
SuggestBox.addEventHandler(SuggestionHandler) method.
CSS Style Rules
.gwt-SuggestBox { the suggest box itself }
.gwt-SuggestBoxPopup { the suggestion popup }
.gwt-SuggestBoxPopup .item { an unselected suggestion }
.gwt-SuggestBoxPopup .item-selected { a selected suggestion }
Constructor for
SuggestBox . The text box will be removed from it's
current location and wrapped by the
SuggestBox .
Parameters: oracle - supplies suggestions based upon the current contents of thetext widget Parameters: box - the text widget
Adds a listener to recieve change events on the SuggestBox's text box.
The source Widget for these events will be the SuggestBox.
Parameters: listener - the listener interface to add
Adds a listener to recieve click events on the SuggestBox's text box.
The source Widget for these events will be the SuggestBox.
Parameters: listener - the listener interface to add
Adds a listener to recieve focus events on the SuggestBox's text box.
The source Widget for these events will be the SuggestBox.
Parameters: listener - the listener interface to add
Adds a listener to recieve keyboard events on the SuggestBox's text box.
The source Widget for these events will be the SuggestBox.
Parameters: listener - the listener interface to add
Gets the limit for the number of suggestions that should be displayed for
this box. It is up to the current
SuggestOracle to enforce this
limit.
the limit for the number of suggestions
Sets the limit to the number of suggestions the oracle should provide. It
is up to the oracle to enforce this limit.
Parameters: limit - the limit to the number of suggestions provided
setPopupStyleName
final public void setPopupStyleName(String style)(Code)
Sets the style name of the suggestion popup.
Parameters: style - the new primary style name See Also:UIObject.setStyleName(String)