com.vaadin.flow.component.radiobutton.

Class RadioButtonGroup<T>

All Implemented Interfaces:

AttachNotifier, DetachNotifier, HasAriaLabel, HasElement, HasEnabled, HasHelper, HasLabel, HasSize, HasStyle, HasTheme, HasValidation, HasValue<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>, HasClientValidation, HasThemeVariant<RadioGroupVariant>, HasTooltip, HasValidationProperties, InputField<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>, HasValidator<T>, HasDataView<T,Void,RadioButtonGroupDataView<T>>, HasListDataView<T,RadioButtonGroupListDataView<T>>, SingleSelect<RadioButtonGroup<T>,T>, Serializable

@Tag("vaadin-radio-group") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.6.3") @NpmPackage(value="@vaadin/radio-group",version="24.6.3") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/radio-group/src/vaadin-radio-group.js") public class RadioButtonGroup<T> extends AbstractSinglePropertyField<RadioButtonGroup<T>,T> implements HasAriaLabel, HasClientValidation, HasDataView<T,Void,RadioButtonGroupDataView<T>>, HasListDataView<T,RadioButtonGroupListDataView<T>>, InputField<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>, HasThemeVariant<RadioGroupVariant>, HasValidationProperties, HasValidator<T>, SingleSelect<RadioButtonGroup<T>,T>

Radio Button Group allows the user to select exactly one value from a list of related but mutually exclusive options.

Validation

Radio Button Group comes with a built-in validation mechanism that verifies that a radio button is selected when required is enabled. Validation is triggered whenever the user selects a radio button or the value is updated programmatically. In practice, however, the required error can only occur if the value is cleared programmatically. This is because radio buttons, by design, don't allow users to clear a selection through UI interaction. If the required error occurs, the component is marked as invalid and an error message is displayed below the group.

The required error message can be configured using either RadioButtonGroup.RadioButtonGroupI18n.setRequiredErrorMessage(String) or HasValidationProperties.setErrorMessage(String).

For more advanced validation that requires custom rules, you can use Binder. Please note that Binder provides its own API for the required validation, see asRequired().

However, if Binder doesn't fit your needs and you want to implement fully custom validation logic, you can disable the built-in validation by setting setManualValidation(boolean) to true. This will allow you to control the invalid state and the error message manually using HasValidationProperties.setInvalid(boolean) and HasValidationProperties.setErrorMessage(String) API.

Author:

Vaadin Ltd.

See Also: