com.vaadin.ui.

Class ComboBox

    • Field Detail

      • pageLength

        protected int pageLength

        Holds value of property pageLength. 0 disables paging.

    • Constructor Detail

      • ComboBox

        public ComboBox()
      • ComboBox

        public ComboBox(String caption)
    • Method Detail

      • getInputPrompt

        public String getInputPrompt()

        Gets the current input prompt.

        Returns:

        the current input prompt, or null if not enabled

        See Also:

        setInputPrompt(String)

      • setInputPrompt

        public void setInputPrompt(String inputPrompt)

        Sets the input prompt - a textual prompt that is displayed when the select would otherwise be empty, to prompt the user for input.

        Parameters:

        inputPrompt - the desired input prompt, or null to disable

      • setTextInputAllowed

        public void setTextInputAllowed(boolean textInputAllowed)

        Sets whether it is possible to input text into the field or whether the field area of the component is just used to show what is selected. By disabling text input, the comboBox will work in the same way as a NativeSelect

        Parameters:

        textInputAllowed - true to allow entering text, false to just show the current selection

        See Also:

        isTextInputAllowed()

      • isTextInputAllowed

        public boolean isTextInputAllowed()

        Returns true if the user can enter text into the field to either filter the selections or enter a new value if AbstractSelect.isNewItemsAllowed() returns true. If text input is disabled, the comboBox will work in the same way as a NativeSelect

        Returns:

      • getState

        protected ComboBoxState 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 AbstractSelect

        Returns:

        updated component shared state

      • getOptionsWithFilter

        protected List<?> getOptionsWithFilter(boolean needNullSelectOption)

        Returns the filtered options for the current page using a container filter. As a size effect, filteredSize is set to the total number of items passing the filter. The current container must be Filterable and Indexed, and the filtering mode must be suitable for container filtering (tested with #canUseContainerFilter()). Use getFilteredOptions() and sanitizeList(List, boolean) if this is not the case.

        Parameters:

        needNullSelectOption -

        Returns:

        filtered list of options (may be empty) or null if cannot use container filters

      • buildFilter

        protected Container.Filter buildFilter(String filterString,
                                               FilteringMode filteringMode)

        Constructs a filter instance to use when using a Filterable container in the ITEM_CAPTION_MODE_PROPERTY mode. Note that the client side implementation expects the filter string to apply to the item caption string it sees, so changing the behavior of this method can cause problems.

        Parameters:

        filterString -

        filteringMode -

        Returns:

      • getFilteredOptions

        protected List<?> getFilteredOptions()

        Filters the options in memory and returns the full filtered list. This can be less efficient than using container filters, so use getOptionsWithFilter(boolean) if possible (filterable container and suitable item caption mode etc.).

        Returns:

      • changeVariables

        public void changeVariables(Object source,
                                    Map<String,Object> variables)

        Invoked when the value of a variable has changed.

        Specified by:

        changeVariables in interface VariableOwner

        Overrides:

        changeVariables in class AbstractSelect

        Parameters:

        source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.

        variables - the Mapping from variable names to new variable values.

        See Also:

        com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)

      • getPageLength

        public int getPageLength()

        Returns the page length of the suggestion popup.

        Returns:

        the pageLength

      • setPageLength

        public void setPageLength(int pageLength)

        Sets the page length for the suggestion popup. Setting the page length to 0 will disable suggestion popup paging (all items visible).

        Parameters:

        pageLength - the pageLength to set

      • setPopupWidth

        public void setPopupWidth(String width)

        Sets the suggestion pop-up's width as a CSS string. By using relative units (e.g. "50%") it's possible to set the popup's width relative to the ComboBox itself.

        Parameters:

        width - the width

        Since:

        7.7

        See Also:

        getPopupWidth()

      • setScrollToSelectedItem

        public void setScrollToSelectedItem(boolean scrollToSelectedItem)

        Sets whether to scroll the selected item visible (directly open the page on which it is) when opening the combo box popup or not. Only applies to single select mode. This requires finding the index of the item, which can be expensive in many large lazy loading containers.

        Parameters:

        scrollToSelectedItem - true to find the page with the selected item when opening the selection popup

      • isScrollToSelectedItem

        public boolean isScrollToSelectedItem()

        Returns true if the select should find the page with the selected item when opening the popup (single select combo box only).

        Returns:

        true if the page with the selected item will be shown when opening the popup

        See Also:

        setScrollToSelectedItem(boolean)

      • setItemStyleGenerator

        public void setItemStyleGenerator(ComboBox.ItemStyleGenerator itemStyleGenerator)

        Sets the item style generator that is used to produce custom styles for showing items in the popup. The CSS class name that will be added to the item style names is v-filterselect-item-[style name].

        Parameters:

        itemStyleGenerator - the item style generator to set, or null to not use any custom item styles

        Since:

        7.5.6

      • getItemStyleGenerator

        public ComboBox.ItemStyleGenerator getItemStyleGenerator()

        Gets the currently used item style generator.

        Returns:

        the itemStyleGenerator the currently used item style generator, or null if no generator is used

        Since:

        7.5.6