Class RadioButtonGroup<T>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,,T>, T> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,,T>, T> HasClientValidation,HasThemeVariant<RadioGroupVariant>,HasTooltip,HasValidationProperties,InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,,T>, T> com.vaadin.flow.data.binder.HasValidator<T>,com.vaadin.flow.data.provider.HasDataView<T,,Void, RadioButtonGroupDataView<T>> com.vaadin.flow.data.provider.HasListDataView<T,,RadioButtonGroupListDataView<T>> com.vaadin.flow.data.selection.SingleSelect<RadioButtonGroup<T>,,T> Serializable
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.RadioButtonGroup(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener) Constructs a radio button group with a value change listener.RadioButtonGroup(String label) Creates an empty radio button group with the defined label.RadioButtonGroup(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener) Constructs a radio button group with the defined label and a value change listener.RadioButtonGroup(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener, T... items) Constructs a radio button group with the defined label, a value change listener and populated with the items in the array.RadioButtonGroup(String label, Collection<T> items) Creates a radio button group with the defined label and populated with the items in the collection.RadioButtonGroup(String label, T... items) Creates a radio button group with the defined label and populated with the items in the array. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.data.provider.DataProvider<T,?> Gets the data provider used by this RadioButtonGroup.Gets the generic data view for the RadioButtonGroup.com.vaadin.flow.function.SerializablePredicate<T>Returns the item enabled predicate.com.vaadin.flow.component.ItemLabelGenerator<T>Gets the item label generator that is used to produce the strings shown in the radio button group for each item.ComponentRenderer<? extends com.vaadin.flow.component.Component,T> Returns the item component renderer.getLabel()String used for the label element.Gets the list data view for the RadioButtonGroup.protected booleanbooleanbooleanSpecifies that the user must select a valueprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidonEnabledStateChanged(boolean enabled) voidsetAriaLabel(String ariaLabel) voidsetAriaLabelledBy(String labelledBy) voidsetDataProvider(com.vaadin.flow.data.provider.DataProvider<T, ?> dataProvider) Sets a generic data provider for the RadioButtonGroup to use.voidsetItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<T> itemEnabledProvider) Sets the item enabled predicate for this radio button group.voidsetItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Sets the item label generator that is used to produce the strings shown in the radio button group for each item.voidSets the label for the field.voidsetManualValidation(boolean enabled) voidsetReadOnly(boolean readOnly) voidsetRenderer(ComponentRenderer<? extends com.vaadin.flow.component.Component, T> renderer) Sets the item renderer for this radio button group.voidsetRequired(boolean required) Specifies that the user must select in a value.voidprotected voidvalidate()protected booleanvalueEquals(T value1, T value2) Compares two value instances to each other to determine whether they are equal.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValueMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListener, getDefaultValidatorMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isRequiredIndicatorVisible, setRequiredIndicatorVisible
-
Constructor Details
-
RadioButtonGroup
public RadioButtonGroup()Default constructor. Creates an empty radio button group. -
RadioButtonGroup
Creates an empty radio button group with the defined label.- Parameters:
label- the label describing the radio button group- See Also:
-
RadioButtonGroup
Creates a radio button group with the defined label and populated with the items in the collection.- Parameters:
label- the label describing the radio button groupitems- the items to be shown in the list of the radio button group- See Also:
-
setLabel(String)HasListDataView.setItems(Collection)
-
RadioButtonGroup
Creates a radio button group with the defined label and populated with the items in the array.- Parameters:
label- the label describing the radio button groupitems- the items to be shown in the list of the radio button group- See Also:
-
setLabel(String)HasListDataView.setItems(Object...)
-
RadioButtonGroup
public RadioButtonGroup(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener) Constructs a radio button group with a value change listener.- Parameters:
listener- the value change listener to add- See Also:
-
AbstractField.addValueChangeListener(ValueChangeListener)
-
RadioButtonGroup
public RadioButtonGroup(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener) Constructs a radio button group with the defined label and a value change listener.- Parameters:
label- the label describing the radio button grouplistener- the value change listener to add- See Also:
-
setLabel(String)AbstractField.addValueChangeListener(ValueChangeListener)
-
RadioButtonGroup
@SafeVarargs public RadioButtonGroup(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>, T>> listener, T... items) Constructs a radio button group with the defined label, a value change listener and populated with the items in the array.- Parameters:
label- the label describing the radio button grouplistener- the value change listener to additems- the items to be shown in the list of the radio button group- See Also:
-
setLabel(String)AbstractField.addValueChangeListener(ValueChangeListener)HasListDataView.setItems(Object...)
-
-
Method Details
-
setItems
public RadioButtonGroupDataView<T> setItems(com.vaadin.flow.data.provider.DataProvider<T, Void> dataProvider) - Specified by:
setItemsin interfacecom.vaadin.flow.data.provider.HasDataView<T,Void, RadioButtonGroupDataView<T>>
-
setItems
public RadioButtonGroupDataView<T> setItems(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider) - Specified by:
setItemsin interfacecom.vaadin.flow.data.provider.HasDataView<T,Void, RadioButtonGroupDataView<T>>
-
setItems
public RadioButtonGroupListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider) - Specified by:
setItemsin interfacecom.vaadin.flow.data.provider.HasListDataView<T,RadioButtonGroupListDataView<T>>
-
getListDataView
Gets the list data view for the RadioButtonGroup. This data view should only be used when the items are in-memory and set with:HasListDataView.setItems(Collection)HasListDataView.setItems(Object[])setItems(ListDataProvider)
- Specified by:
getListDataViewin interfacecom.vaadin.flow.data.provider.HasListDataView<T,RadioButtonGroupListDataView<T>> - Returns:
- the list data view that provides access to the data bound to the RadioButtonGroup
-
getGenericDataView
Gets the generic data view for the RadioButtonGroup. This data view should only be used whengetListDataView()is not applicable for the underlying data provider.- Specified by:
getGenericDataViewin interfacecom.vaadin.flow.data.provider.HasDataView<T,Void, RadioButtonGroupDataView<T>> - Returns:
- the generic DataView instance implementing
RadioButtonGroupDataView
-
hasValidValue
protected boolean hasValidValue()- Overrides:
hasValidValuein classcom.vaadin.flow.component.AbstractSinglePropertyField<RadioButtonGroup<T>,T>
-
setDataProvider
Sets a generic data provider for the RadioButtonGroup to use.Use this method when none of the
setItemsmethods are applicable, e.g. when having a data provider with filter that cannot be transformed toDataProvider<T, Void>.- Parameters:
dataProvider- DataProvider instance to use, notnull
-
setItemLabelGenerator
public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Sets the item label generator that is used to produce the strings shown in the radio button group for each item. By default,String.valueOf(Object)is used.Setting an item label generator removes any previously set item renderer.
- Parameters:
itemLabelGenerator- the item label provider to use, not null
-
getItemLabelGenerator
Gets the item label generator that is used to produce the strings shown in the radio button group for each item.- Returns:
- the item label generator used, not null
-
setValue
- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>, T> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<RadioButtonGroup<T>,T>
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
getDataProvider
Gets the data provider used by this RadioButtonGroup.To get information and control over the items in the RadioButtonGroup, use either
getListDataView()orgetGenericDataView()instead.- Returns:
- the data provider used by this RadioButtonGroup
-
getItemEnabledProvider
Returns the item enabled predicate.- Returns:
- the item enabled predicate
- See Also:
-
setItemEnabledProvider
public void setItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<T> itemEnabledProvider) Sets the item enabled predicate for this radio button 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, notnull
-
getItemRenderer
Returns the item component renderer.- Returns:
- the item renderer
- See Also:
-
setRenderer
public void setRenderer(ComponentRenderer<? extends com.vaadin.flow.component.Component, T> renderer) Sets the item renderer for this radio button group. The renderer is applied to each item to create a component which represents the item.Note: Component acts as a label to the button and clicks on it trigger the radio button. Hence interactive components like DatePicker or ComboBox cannot be used.
- Parameters:
renderer- the item renderer, notnull
-
onEnabledStateChanged
public void onEnabledStateChanged(boolean enabled) - Overrides:
onEnabledStateChangedin classcom.vaadin.flow.component.Component
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>, T> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>, T>
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>, T> - Specified by:
isReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>, T>
-
setRequired
public void setRequired(boolean required) Specifies that the user must select in a value.NOTE: The required indicator will not be visible, if there is no
labelproperty set for the RadioButtonGroup.- Parameters:
required- the boolean value to set
-
isRequired
public boolean isRequired()Specifies that the user must select a valueThis property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Returns:
- the
requiredproperty from the webcomponent
-
setLabel
Sets the label for the field.- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel- Parameters:
label- value for thelabelproperty in the webcomponent
-
getLabel
String used for the label element.- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel- Returns:
- the
labelproperty from the webcomponent
-
setAriaLabel
- Specified by:
setAriaLabelin interfacecom.vaadin.flow.component.HasAriaLabel
-
getAriaLabel
- Specified by:
getAriaLabelin interfacecom.vaadin.flow.component.HasAriaLabel
-
setAriaLabelledBy
- Specified by:
setAriaLabelledByin interfacecom.vaadin.flow.component.HasAriaLabel
-
getAriaLabelledBy
- Specified by:
getAriaLabelledByin interfacecom.vaadin.flow.component.HasAriaLabel
-
valueEquals
Compares two value instances to each other to determine whether they are equal. Equality is used to determine whether to update internal state and fire an event whensetValue(Object)orAbstractField.setModelValue(Object, boolean)is called. Subclasses can override this method to define an alternative comparison method instead ofObject.equals(Object).- Overrides:
valueEqualsin classcom.vaadin.flow.component.AbstractField<RadioButtonGroup<T>,T> - Parameters:
value1- the first instancevalue2- the second instance- Returns:
trueif the instances are equal; otherwisefalse
-
setManualValidation
public void setManualValidation(boolean enabled) - Specified by:
setManualValidationin interfacecom.vaadin.flow.component.HasValidation
-
validate
protected void validate()
-