@NpmPackage(value="@vaadin/radio-group",version="22.0.7") @NpmPackage(value="@vaadin/vaadin-radio-button",version="22.0.7") public class RadioButtonGroup<T> extends GeneratedVaadinRadioGroup<RadioButtonGroup<T>,T> implements HasItemComponents<T>, SingleSelect<RadioButtonGroup<T>,T>, HasListDataView<T,RadioButtonGroupListDataView<T>>, HasDataView<T,Void,RadioButtonGroupDataView<T>>, HasValidation, HasHelper, HasSize
This is a server side Java integration for the vaadin-radio-group
element.
Usage examples, see the demo in vaadin.com.
GeneratedVaadinRadioGroup.InvalidChangeEvent<R extends GeneratedVaadinRadioGroup<R,?>>
AbstractField.ComponentValueChangeEvent<C extends Component,V>
HasItemComponents.ItemComponent<T>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
Constructor and Description |
---|
RadioButtonGroup() |
Modifier and Type | Method and Description |
---|---|
DataProvider<T,?> |
getDataProvider()
Deprecated.
use
getListDataView() or
getGenericDataView() instead |
String |
getErrorMessage()
Gets the current error message from the radio button group.
|
RadioButtonGroupDataView<T> |
getGenericDataView()
Gets the generic data view for the RadioButtonGroup.
|
SerializablePredicate<T> |
getItemEnabledProvider()
Returns the item enabled predicate.
|
ComponentRenderer<? extends Component,T> |
getItemRenderer()
Returns the item component renderer.
|
String |
getLabel()
String used for the label element.
|
RadioButtonGroupListDataView<T> |
getListDataView()
Gets the list data view for the RadioButtonGroup.
|
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()
Specifies that the user must select a value
|
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
protected void |
onDetach(DetachEvent detachEvent)
Called when the component is detached from a UI.
|
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 RadioButtonGroupListDataView or
RadioButtonGroupDataView |
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 radio button group.
|
RadioButtonGroupDataView<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. |
RadioButtonGroupDataView<T> |
setItems(InMemoryDataProvider<T> inMemoryDataProvider)
Sets an in-memory data provider for the component to use
|
RadioButtonGroupListDataView<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 |
setRenderer(ComponentRenderer<? extends Component,T> renderer)
Sets the item renderer for this radio button group.
|
void |
setRequired(boolean required)
Specifies that the user must select in a value.
|
void |
setValue(T value)
Sets the value of this object.
|
protected boolean |
valueEquals(T value1,
T value2)
Compares two value instances to each other to determine whether they are
equal.
|
addInvalidChangeListener, addThemeVariants, checkValidity, getErrorMessageString, getLabelString, isDisabledBoolean, isInvalidBoolean, isReadonlyBoolean, isRequiredBoolean, removeThemeVariants, setDisabled, setReadonly, validate
getSynchronizationRegistration, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addComponents, getItemPosition, prependComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
isRequiredIndicatorVisible, setRequiredIndicatorVisible
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty
isEnabled, setEnabled
setItems, setItems
getHelperComponent, getHelperText, setHelperComponent, setHelperText
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
addAttachListener
addDetachListener
public RadioButtonGroupDataView<T> setItems(DataProvider<T,Void> dataProvider)
HasDataView
DataView
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,RadioButtonGroupDataView<T>>
dataProvider
- DataProvider instance to use, not null
public RadioButtonGroupDataView<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,RadioButtonGroupDataView<T>>
inMemoryDataProvider
- InMemoryDataProvider to use, not null
public RadioButtonGroupListDataView<T> setItems(ListDataProvider<T> dataProvider)
HasListDataView
ListDataView
that provides information and allows operations on
the items.setItems
in interface HasListDataView<T,RadioButtonGroupListDataView<T>>
dataProvider
- ListDataProvider providing items to the component.@Deprecated public void setItems(Stream<T> streamOfItems)
HasListDataView.setItems(Collection)
instead.public RadioButtonGroupListDataView<T> getListDataView()
getListDataView
in interface HasListDataView<T,RadioButtonGroupListDataView<T>>
public RadioButtonGroupDataView<T> getGenericDataView()
getListDataView()
is not applicable for
the underlying data provider.getGenericDataView
in interface HasDataView<T,Void,RadioButtonGroupDataView<T>>
RadioButtonGroupDataView
protected boolean hasValidValue()
AbstractSinglePropertyField
false
. The default implementation always
return true
.hasValidValue
in class AbstractSinglePropertyField<RadioButtonGroup<T>,T>
true
if the element property value can be converted
to the model type; otherwise false
@Deprecated public void setDataProvider(DataProvider<T,?> dataProvider)
setItems
methods which provide
access to either RadioButtonGroupListDataView
or
RadioButtonGroupDataView
public void setValue(T value)
HasValue
getValue()
, fires a value change event. May throw
IllegalArgumentException
if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue()
if the empty value is not null
.
setValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>
setValue
in class AbstractField<RadioButtonGroup<T>,T>
value
- the new valueprotected void onAttach(AttachEvent attachEvent)
Component
The default implementation does nothing.
This method is invoked before the AttachEvent
is fired for the
component.
protected void onDetach(DetachEvent detachEvent)
Component
The default implementation does nothing.
This method is invoked before the DetachEvent
is fired for the
component.
@Deprecated public DataProvider<T,?> getDataProvider()
getListDataView()
or
getGenericDataView()
insteadnull
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 null
public ComponentRenderer<? extends Component,T> getItemRenderer()
setRenderer(ComponentRenderer)
public void setRenderer(ComponentRenderer<? extends Component,T> renderer)
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.
renderer
- the item renderer, not null
public void onEnabledStateChanged(boolean enabled)
Component
By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
onEnabledStateChanged
in class Component
enabled
- the new enabled state of the componentpublic void setReadOnly(boolean readOnly)
HasValue
HasValue
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<RadioButtonGroup<T>,T>,T>
setReadOnly
in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>
readOnly
- a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
HasValue
HasValue
is in read-only mode or not.isReadOnly
in interface HasValue<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>
isReadOnly
in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<RadioButtonGroup<T>,T>,T>
false
if the user can modify the value, true
if
not.public void setRequired(boolean required)
NOTE: The required indicator will not be visible, if there is no
label
property set for the RadioButtonGroup.
setRequired
in class GeneratedVaadinRadioGroup<RadioButtonGroup<T>,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.
required
property from the webcomponentpublic void setErrorMessage(String errorMessage)
GeneratedVaadinRadioGroup
Description copied from corresponding location in WebComponent:
Error to show when the input value is invalid.
setErrorMessage
in interface HasValidation
setErrorMessage
in class GeneratedVaadinRadioGroup<RadioButtonGroup<T>,T>
errorMessage
- the String value to setpublic String getErrorMessage()
getErrorMessage
in interface HasValidation
public void setLabel(String label)
GeneratedVaadinRadioGroup
Description copied from corresponding location in WebComponent:
String used for the label element.
setLabel
in class GeneratedVaadinRadioGroup<RadioButtonGroup<T>,T>
label
- the String value to setpublic String getLabel()
label
property from the webcomponentpublic boolean isInvalid()
HasValidation
true
if component input is invalid, false
otherwise.isInvalid
in interface HasValidation
public void setInvalid(boolean invalid)
GeneratedVaadinRadioGroup
Description copied from corresponding location in WebComponent:
This property is set to true when the value is invalid.
setInvalid
in interface HasValidation
setInvalid
in class GeneratedVaadinRadioGroup<RadioButtonGroup<T>,T>
invalid
- the boolean value to setprotected boolean valueEquals(T value1, T value2)
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<RadioButtonGroup<T>,T>
value1
- the first instancevalue2
- the second instancetrue
if the instances are equal; otherwise
false
Copyright © 2022. All rights reserved.