com.vaadin.flow.component.checkbox.

Class CheckboxGroup<T>

    • Constructor Detail

      • CheckboxGroup

        public CheckboxGroup()
    • Method Detail

      • 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

      • updateSelection

        public void updateSelection(Set<T> addedItems,
                                    Set<T> removedItems)

        Description copied from interface: MultiSelect

        Updates the selection by adding and removing the given items from it.

        If all the added items were already selected and the removed items were not selected, this is a NO-OP.

        Duplicate items (in both add and remove sets) are ignored.

        Specified by:

        updateSelection in interface MultiSelect<CheckboxGroup<T>,T>

        Parameters:

        addedItems - the items to add, not null

        removedItems - the items to remove, not null

      • getSelectedItems

        public Set<T> getSelectedItems()

        Description copied from interface: MultiSelect

        Returns an immutable set of the currently selected items. It is safe to invoke other SelectionModel methods while iterating over the set.

        Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.

        Specified by:

        getSelectedItems in interface MultiSelect<CheckboxGroup<T>,T>

        Returns:

        the items in the current selection, not null

      • getDataProvider

        public DataProvider<T,?> getDataProvider()

        Gets the data provider.

        Returns:

        the data provider, not null

      • onEnabledStateChanged

        public void onEnabledStateChanged(boolean enabled)

        Description copied from class: Component

        Handle component enable state when the enabled state changes.

        By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.

        Overrides:

        onEnabledStateChanged in class Component

        Parameters:

        enabled - the new enabled state of the component

      • setItemEnabledProvider

        public void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)

        Sets the item enabled predicate for this checkbox group. The predicate is applied to each item to determine whether the item should be enabled (true) or disabled (false). Disabled items are displayed as grayed out and the user cannot select them. The default predicate always returns true (all the items are enabled).

        Parameters:

        itemEnabledProvider - the item enable predicate, not null

      • setItemLabelGenerator

        public void setItemLabelGenerator(ItemLabelGenerator<T> itemLabelGenerator)

        Sets the item label generator that is used to produce the strings shown in the checkbox group for each item. By default, String.valueOf(Object) is used.

        Parameters:

        itemLabelGenerator - the item label provider to use, not null

      • getItemLabelGenerator

        public ItemLabelGenerator<T> getItemLabelGenerator()

        Gets the item label generator that is used to produce the strings shown in the checkbox group for each item.

        Returns:

        the item label generator used, not null

      • getLabel

        public String getLabel()

        Gets the label of the checkbox group.

        Returns:

        the label property of the checkbox group

      • getErrorMessage

        public String getErrorMessage()

        Gets the current error message from the checkbox group.

        Specified by:

        getErrorMessage in interface HasValidation

        Returns:

        the current error message

      • isRequired

        public boolean isRequired()

        Determines whether the checkbox group is marked as input required.

        This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.

        Returns:

        true if the input is required, false otherwise

      • isInvalid

        public boolean isInvalid()

        Description copied from interface: HasValidation

        Returns true if component input is invalid, false otherwise.

        Specified by:

        isInvalid in interface HasValidation

        Returns:

        whether the component input is valid

      • hasValidValue

        protected boolean hasValidValue()

        Description copied from class: AbstractSinglePropertyField

        Checks whether the element property has a value that can be converted to the model type. Property changes from the element will be ignored if this method returns false. The default implementation always return true.

        Overrides:

        hasValidValue in class AbstractSinglePropertyField<CheckboxGroup<T>,Set<T>>

        Returns:

        true if the element property value can be converted to the model type; otherwise false