com.vaadin.ui.

Class NativeSelect<T>

    • Constructor Detail

      • NativeSelect

        public NativeSelect()

        Creates a new NativeSelect with an empty caption and no items.

      • NativeSelect

        public NativeSelect​(String caption)

        Creates a new NativeSelect with the given caption and no items.

        Parameters:

        caption - the component caption to set, null for no caption

      • NativeSelect

        public NativeSelect​(String caption,
                            Collection<T> items)

        Creates a new NativeSelect with the given caption, containing the data items in the given collection.

        Parameters:

        caption - the component caption to set, null for no caption

        items - the data items to use, not null

      • NativeSelect

        public NativeSelect​(String caption,
                            DataProvider<T,​?> dataProvider)

        Creates a new NativeSelect with the given caption, using the given DataProvider as the source of data items.

        Parameters:

        caption - the component caption to set, null for no caption

        dataProvider - the source of data items to use, not null

    • Method Detail

      • getState

        protected NativeSelectState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractSingleSelect<T>

        Returns:

        updated component shared state

      • getDataProvider

        public DataProvider<T,​?> getDataProvider()

        Description copied from interface: HasItems

        Returns the source of data items used by this listing.

        Specified by:

        getDataProvider in interface HasItems<T>

        Returns:

        the data provider, not null

      • setDataProvider

        public void setDataProvider​(DataProvider<T,​?> dataProvider)

        Description copied from interface: HasDataProvider

        Sets the data provider for this listing. The data provider is queried for displayed items as needed.

        Specified by:

        setDataProvider in interface HasDataProvider<T>

        Parameters:

        dataProvider - the data provider, not null

      • isEmptySelectionAllowed

        public boolean isEmptySelectionAllowed()

        Returns whether the user is allowed to select nothing in the combo box.

        Returns:

        true if empty selection is allowed, false otherwise

        Since:

        8.0

      • setEmptySelectionAllowed

        public void setEmptySelectionAllowed​(boolean emptySelectionAllowed)

        Sets whether the user is allowed to select nothing in the combo box. When true, a special empty item is shown to the user.

        Parameters:

        emptySelectionAllowed - true to allow not selecting anything, false to require selection

        Since:

        8.0

      • setEmptySelectionCaption

        public void setEmptySelectionCaption​(String caption)

        Sets the empty selection caption.

        The empty string "" is the default empty selection caption.

        If empty selection is allowed via the setEmptySelectionAllowed(boolean) method (it is by default) then the empty item will be shown with the given caption.

        Parameters:

        caption - the caption to set, not null

        Since:

        8.0

        See Also:

        AbstractSingleSelect.isSelected(Object)

      • setVisibleItemCount

        public void setVisibleItemCount​(int visibleItemCount)

        Sets the number of items that are visible. If only one item is visible, then the box will be displayed as a drop-down list (the default).

        Parameters:

        visibleItemCount - the visible item count

        Throws:

        IllegalArgumentException - if the value is smaller than one

        Since:

        8.1

      • getVisibleItemCount

        public int getVisibleItemCount()

        Gets the number of items that are visible. If only one item is visible, then the box will be displayed as a drop-down list.

        Returns:

        the visible item count

        Since:

        8.1