ComboBox, Select and ListBox

These three components allow the user to select an option from a list of options. These components differ as follows:

  • The ComboBox allows the user to search for the desired object.

  • The Select allows the user to select the desired object from a list.

  • With the ListBox the list does not have to be opened by a click first.

The values of these components can be set as follows:

  1. Drag and drop the component onto the view.

  2. Drag and drop an entity onto the component.

  3. Then in the following dialog select which text should be displayed.

  4. Then in the properties under Data > DataProvider select the query which will be used to populate the component from the database.
    Alternatively: the component can also be filled by code. To do this, you can extend the constructor of the view as follows:

    public MainLayout()
    {
        super();
        this.initUI();
    
        this.combobox.setItems(
            new Kunde("Hans", "Robert"),
            new Kunde("Joachim", "Schmidt"),
            new Kunde("Lars", "Sommermann"));
    }
  5. You can then get the selected customers via combobox.getValue().

Important properties of the ComboBox:

  • Required - Indicates that the user must fill in the field before clicking Next in a form, for example.

  • ClearButtonVisible - Specifies whether to display a button that allows the user to reset the set value.

  • Label - description displayed above the element.

  • PageSize - number of how many items can be displayed in the list at once.

  • Placeholder - text that will be displayed if the field has no content yet.

Important properties of the select:

  • Label - description displayed above the element.

  • EmptySelectionAllowed - Indicates whether the field is valid even without selection.

  • Placeholder - text that will be displayed if the field has no content yet.