Introduction
In this blog, we are going to learn what a suggested box is and how we implement a SuggestBox using GWT also we will get to know about some inbuilt methods of GWT that will assist us in efficiently implementing it.
But before that let's get to know about GWT.
GWT

A development toolkit called GWT enables programmers to create internet or web applications. For typical web-app chores like bookmarking, UI abstraction, cross-browser compatibility, etc., GWT insists on reusable techniques. It offers characteristics like:
-
Because GWT solves browser incompatibilities through various bindings, developers do not need to be experts in this area.
-
The client and server code bases for GWT are the same.
-
Java was the platform of choice for GWT because it offers features like code navigation and refactoring that make development more efficient.
-
GWT MVP (Model View Presenter) enables collaborative working and more rapid JUnit testing. By adding events to the event bus, the client-side program can make several modifications.
- It enables the integration of numerous Java technologies, including hibernate via gilead.
SuggestionBox
The SuggestionBox widget simulates a text box or text area that shows a series of pre-configured options that correspond to the user's input. One SuggestOracle is connected to each SuggestBox. Given a specified query string, the SuggestOracle is used to suggest a collection of choices.
Class declaration of suggestionbox in GWT
com.google.gwt.user.client.ui.SuggestionBoxLets see the extended version of class SuggestionBox:
public final class SuggestBox
extends Composite
implements HasText, HasFocus, HasAnimation,
SourcesClickEvents, SourcesFocusEvents,
SourcesChangeEvents, SourcesKeyboardEvents,
FiresSuggestionEvents
Following are the class constructors we can implement in GWT suggestionbox class
Sr.no |
Constructors in GWT |
1. |
SuggestBox() |
2. |
SuggestBox(SuggestOracle oracle) |
3. |
SuggestBox(SuggestOracle oracle, TextBoxBase box) |
Below are the class methods we can use in the SuggestionBox to implement various features.
Class Methods:
Sr.no |
Methods and Description |
|
1.
|
void addChangeListener(ChangeListener listener)
Establishes a listener to receive change events for the text box of the SuggestBox. |
2. |
void addClickListener(ClickListener listener)
the addition of a listener to receive click events on the text box of the SuggestBox. |
|
3.
|
void addEventHandler(SuggestionHandler handler)
the addition of a handler interface for recommendation event reception. |
4. |
void addFocusListener(FocusListener listener) the addition of a listener to receive focus events on the text box of the SuggestBox. |
5. |
void addKeyboardListener(KeyboardListener listener)
Adds a listener to the SuggestBox's text box to receive keyboard events. |
6. |
int getLimit()
The maximum number of suggestions that can be displayed in this box is obtained. |
7. |
SuggestOracle getSuggestOracle() gets the SuggestOracle from the suggestion box. |
8. |
int getTabIndex() retrieves the widget's tab index position. |
9. |
java.lang.String getText()
retrieves the text of this object. |
10. |
boolean isAnimationEnabled() determines whether animation is on or off. |
There are more methods available in suggestbox class that you can search and implement in your code.





