Description and Features List

Pop-up calendar simplifies date and time entering

Pop-up calendar simplifies date and time entering

Text and Button Components is a class of GWT widgets which has a text box and a button joined in one component. The oldest widget of this class is the Date Picker. It allows entering date and time using pop-up calendar panel. Major features of the Date Picker are:

  • Internationalization support
  • Ability to enter date and time or date only
  • Popup calendar
  • Customizable date formatting

Combo Box allows entering your own custom value instead of choosing it in the drop down list

Combo Box allows entering your own custom value instead of choosing it in the drop down list

Another one widget is ComboBox. You can enter a new value directly in the text field or choosing it from the drop down list. Key features of this widget listed below:

  • Ability to switch on / off custom text entering
  • Complex drop down list items support, for example, textual objects with icons
  • Transparent GWT event model support
  • Data model support (MVP pattern implementation)
  • Moving selection cursor with keyboard
  • Data model events
  • Lazy rendering
  • Manageable drop down list position
  • Items multiple insertion

Displaying complex drop down list items is not a big deal for the Suggestion Box

Displaying complex drop down list items is not a big deal for the Suggestion Box

And the last widget is the Suggestion Box. It's an extension of the Combo Box and supports the same features but has several additional ones:

  • Ability to load drop down list items lazily
  • Customizable expression (text) change handler
  • Lazy rendering

Samples

The sample below shows how to use the Date Picker


DatePicker picker = new DatePicker(new Date());
// swicth off time entering
picker.setTimeVisible(false);

The next sample demonstrates how to create a new Suggestion Box and make it fill the model on change.


//create the model and callback handler
SuggestionBoxDataModel model = new SuggestionBoxDataModel(new ListCallbackHandler(){
public void fill(ListDataModel model) {
    if ("John".equals(((SuggestionBoxDataModel)model).getExpression())) {
        //remove old values
        model.clear();

        //add Johns
        model.add("john1", "John Doe");
        model.add("john2", "John Parkinson");
        model.add("john3", "John Todd");
    } else {
        //remove old values
        model.clear();

        //add default item
        model.add("", "Nobody");
    }
}
});

//initilize the suggestion box
SuggestionBox box = new SuggestionBox();
box.setModel(model);
box.setMaxLength(3);

The source code for the Combo Box will be similar but note that you can't create callback handlers.