public class CheckboxGroup<T> extends GeneratedVaadinCheckboxGroup<CheckboxGroup<T>,Set<T>> implements HasItemComponents<T>, HasSize, HasValidation, MultiSelect<CheckboxGroup<T>,T>, HasListDataView<T,CheckboxGroupListDataView<T>>, HasDataView<T,Void,CheckboxGroupDataView<T>>, HasHelper
vaadin-checkbox-group element.
CheckBoxGroup is a multiselection component where items are displayed as check boxes.
GeneratedVaadinCheckboxGroup.InvalidChangeEvent<R extends GeneratedVaadinCheckboxGroup<R,?>>AbstractField.ComponentValueChangeEvent<C extends Component,V>HasItemComponents.ItemComponent<T>HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>| Constructor and Description |
|---|
CheckboxGroup() |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addSelectionListener(MultiSelectionListener<CheckboxGroup<T>,T> listener)
Adds a selection listener that will be called when the selection is
changed either by the user or programmatically.
|
DataProvider<T,?> |
getDataProvider()
Deprecated.
use
getListDataView() or
getGenericDataView() instead |
String |
getErrorMessage()
Gets the current error message from the checkbox group.
|
CheckboxGroupDataView<T> |
getGenericDataView()
Gets the generic data view for the checkbox group.
|
SerializablePredicate<T> |
getItemEnabledProvider()
Returns the item enabled predicate.
|
ItemLabelGenerator<T> |
getItemLabelGenerator()
Gets the item label generator that is used to produce the strings shown
in the checkbox group for each item.
|
String |
getLabel()
Gets the label of the checkbox group.
|
CheckboxGroupListDataView<T> |
getListDataView()
Gets the list data view for the checkbox group.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
protected boolean |
hasValidValue()
Checks whether the element property has a value that can be converted to
the model type.
|
boolean |
isInvalid()
Returns
true if component input is invalid, false
otherwise. |
boolean |
isReadOnly()
Returns whether this
HasValue is in read-only mode or not. |
boolean |
isRequired()
Determines whether the checkbox group is marked as input required.
|
void |
onEnabledStateChanged(boolean enabled)
Handle component enable state when the enabled state changes.
|
void |
setDataProvider(DataProvider<T,?> dataProvider)
Deprecated.
use instead one of the
setItems methods which provide
access to either CheckboxGroupListDataView or
CheckboxGroupDataView |
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
void |
setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Sets the item enabled predicate for this checkbox group.
|
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.
|
CheckboxGroupDataView<T> |
setItems(DataProvider<T,Void> dataProvider)
Set a generic data provider for the component to use and returns the base
DataView that provides API to get information on the items. |
CheckboxGroupDataView<T> |
setItems(InMemoryDataProvider<T> inMemoryDataProvider)
Sets an in-memory data provider for the component to use
|
CheckboxGroupListDataView<T> |
setItems(ListDataProvider<T> dataProvider)
Sets a ListDataProvider for the component to use and returns a
ListDataView that provides information and allows operations on
the items. |
void |
setItems(Stream<T> streamOfItems)
Deprecated.
Because the stream is collected to a list anyway, use
HasListDataView.setItems(Collection) instead. |
void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of this
HasValue to given mode. |
void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
void |
setValue(Set<T> value)
Sets the value of this component.
|
void |
updateSelection(Set<T> addedItems,
Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
|
protected boolean |
valueEquals(Set<T> value1,
Set<T> value2)
Compares to value instances to each other to determine whether they are
equal.
|
addInvalidChangeListener, addThemeVariants, getErrorMessageString, getLabelString, isDisabledBoolean, isInvalidBoolean, isRequiredBoolean, removeThemeVariants, setDisabled, validategetSynchronizationRegistration, setPresentationValue, setSynchronizedEventaddValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValueaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddComponents, getItemPosition, prependComponentsadd, add, addComponentAsFirst, addComponentAtIndex, remove, removeAllgetCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFulldeselect, deselect, deselectAll, getEmptyValue, getValue, isSelected, select, selectisRequiredIndicatorVisible, setRequiredIndicatorVisibleaddValueChangeListener, clear, getOptionalValue, isEmptyisEnabled, setEnabledsetItems, setItemsgetHelperComponent, getHelperText, setHelperComponent, setHelperTextaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameaddThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameaddAttachListeneraddDetachListenerpublic CheckboxGroupDataView<T> setItems(DataProvider<T,Void> dataProvider)
HasDataViewDataView that provides API to get information on the items.
This method should be used only when the data provider type is not either
ListDataProvider or BackEndDataProvider.
setItems in interface HasDataView<T,Void,CheckboxGroupDataView<T>>dataProvider - DataProvider instance to use, not nullpublic CheckboxGroupDataView<T> setItems(InMemoryDataProvider<T> inMemoryDataProvider)
HasDataView
Note! Using a ListDataProvider instead of a
InMemoryDataProvider is recommended to get access to
ListDataView API by using
HasListDataView.setItems(ListDataProvider).
setItems in interface HasDataView<T,Void,CheckboxGroupDataView<T>>inMemoryDataProvider - InMemoryDataProvider to use, not nullpublic CheckboxGroupListDataView<T> setItems(ListDataProvider<T> dataProvider)
HasListDataViewListDataView that provides information and allows operations on
the items.setItems in interface HasListDataView<T,CheckboxGroupListDataView<T>>dataProvider - ListDataProvider providing items to the component.public CheckboxGroupListDataView<T> getListDataView()
getListDataView in interface HasListDataView<T,CheckboxGroupListDataView<T>>public CheckboxGroupDataView<T> getGenericDataView()
getListDataView() is not applicable for the
underlying data provider.getGenericDataView in interface HasDataView<T,Void,CheckboxGroupDataView<T>>CheckboxGroupDataView@Deprecated public void setItems(Stream<T> streamOfItems)
HasListDataView.setItems(Collection) instead.@Deprecated public void setDataProvider(DataProvider<T,?> dataProvider)
setItems methods which provide
access to either CheckboxGroupListDataView or
CheckboxGroupDataViewpublic void updateSelection(Set<T> addedItems, Set<T> removedItems)
MultiSelectIf 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.
updateSelection in interface MultiSelect<CheckboxGroup<T>,T>addedItems - the items to add, not nullremovedItems - the items to remove, not nullpublic void setValue(Set<T> value)
The component doesn't accept null values. The value of a checkbox
group without any selected items is an empty set. You can use the
HasValue.clear() method to set the empty value.
setValue in interface HasValue<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>setValue in interface MultiSelect<CheckboxGroup<T>,T>setValue in class AbstractField<CheckboxGroup<T>,Set<T>>value - the new value to set, not nullNullPointerException - if value is nullpublic Set<T> getSelectedItems()
MultiSelectSelectionModel 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.
getSelectedItems in interface MultiSelect<CheckboxGroup<T>,T>nullpublic Registration addSelectionListener(MultiSelectionListener<CheckboxGroup<T>,T> listener)
MultiSelectaddSelectionListener in interface MultiSelect<CheckboxGroup<T>,T>listener - the value change listener, not null@Deprecated public DataProvider<T,?> getDataProvider()
getListDataView() or
getGenericDataView() insteadnullpublic void onEnabledStateChanged(boolean enabled)
ComponentBy default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
onEnabledStateChanged in class Componentenabled - the new enabled state of the componentpublic void setReadOnly(boolean readOnly)
HasValueHasValue to given mode. The user
can't change the value when in read-only mode.
A HasValue with a visual component in read-only mode typically
looks visually different to signal to the user that the value cannot be
edited.
setReadOnly in interface HasValue<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>setReadOnly in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>readOnly - a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
HasValueHasValue is in read-only mode or not.isReadOnly in interface HasValue<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>isReadOnly in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>false if the user can modify the value, true if
not.public SerializablePredicate<T> getItemEnabledProvider()
setItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<T>)public void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
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).itemEnabledProvider - the item enable predicate, not nullpublic void setItemLabelGenerator(ItemLabelGenerator<T> itemLabelGenerator)
String.valueOf(Object) is used.itemLabelGenerator - the item label provider to use, not nullpublic ItemLabelGenerator<T> getItemLabelGenerator()
public void setLabel(String label)
GeneratedVaadinCheckboxGroupDescription copied from corresponding location in WebComponent:
String used for the label element.
setLabel in class GeneratedVaadinCheckboxGroup<CheckboxGroup<T>,Set<T>>label - the String value to setpublic String getLabel()
label property of the checkbox grouppublic void setErrorMessage(String errorMessage)
GeneratedVaadinCheckboxGroupDescription copied from corresponding location in WebComponent:
Error to show when the input value is invalid.
setErrorMessage in interface HasValidationsetErrorMessage in class GeneratedVaadinCheckboxGroup<CheckboxGroup<T>,Set<T>>errorMessage - the String value to setpublic String getErrorMessage()
getErrorMessage in interface HasValidationpublic void setRequired(boolean required)
GeneratedVaadinCheckboxGroupDescription copied from corresponding location in WebComponent:
Specifies that the user must fill in a value.
setRequired in class GeneratedVaadinCheckboxGroup<CheckboxGroup<T>,Set<T>>required - the boolean value to setpublic boolean isRequired()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
true if the input is required, false otherwisepublic boolean isInvalid()
HasValidationtrue if component input is invalid, false
otherwise.isInvalid in interface HasValidationpublic void setInvalid(boolean invalid)
GeneratedVaadinCheckboxGroupDescription copied from corresponding location in WebComponent:
This property is set to true when the control value is invalid.
setInvalid in interface HasValidationsetInvalid in class GeneratedVaadinCheckboxGroup<CheckboxGroup<T>,Set<T>>invalid - the boolean value to setprotected boolean valueEquals(Set<T> value1, Set<T> value2)
AbstractFieldAbstractField.setValue(Object) or
AbstractField.setModelValue(Object, boolean) is called. Subclasses can
override this method to define an alternative comparison method instead
of Object.equals(Object).valueEquals in class AbstractField<CheckboxGroup<T>,Set<T>>value1 - the first instancevalue2 - the second instancetrue if the instances are equal; otherwise
falseprotected boolean hasValidValue()
AbstractSinglePropertyFieldfalse. The default implementation always
return true.hasValidValue in class AbstractSinglePropertyField<CheckboxGroup<T>,Set<T>>true if the element property value can be converted
to the model type; otherwise falseCopyright © 2021. All rights reserved.