This implementation guarantees that radio buttons belonging to the same group have the same name attribute. It provides an API for managing the radio buttons as a group and ensures that selecting one radio deselects others in the same group.
T
The type of the value associated with the radio buttons in the group.
Radio buttons are typically used to allow users to make a single selection from a list of options. A radio button can have a label and optional helper text.
Usage Example:
Radio< String> radio = Radio.create("option1", "Option 1");
radio.setHelperText("Select option 1"); radio.addValueChangeHandler(value -> {
Window.alert("Selected value: " + value); });
T
The type of value associated with the radio button.
See also :
public void RadioGroup(String name)
name
The name attribute for the radio group.
public void RadioGroup(String name, String label)
name
The name attribute for the radio group.
label
The label for the radio group.
public static RadioGroup<T> create(String name)
T
The type of the value associated with the radio buttons in the group.
name
The name attribute for the radio group.
A new instance of RadioGroup.
public static RadioGroup<T> create(String name, String label)
T
The type of the value associated with the radio buttons in the group.
name
The name attribute for the radio group.
label
The label for the radio group.
A new instance of RadioGroup.
public RadioGroup<T> withGap(boolean withGap)
withGap
A boolean flag indicating whether to add gaps between radio the radio border and the selected indicator circle at the middle.
The instance of the RadioGroup .
public RadioGroup<T> appendChild(Radio<? extends T> radio)
radio
The Radio to be appended to the group.
The instance of the RadioGroup .
public RadioGroup<T> removeRadio(Radio<? extends T> radio, boolean silent)
radio
The Radio to be removed.
silent
A boolean flag indicating if the uncheck action should trigger events.
The instance of the RadioGroup .
public RadioGroup<T> removeAllRadios(boolean silent)
silent
A boolean flag indicating if the uncheck action for each radio should trigger events.
The instance of the RadioGroup .
public RadioGroup<T> clear(boolean silent)
silent
A boolean flag indicating if the check action should trigger events.
The instance of the RadioGroup .
public RadioGroup<T> triggerChangeListeners(T oldValue, T newValue)
oldValue
The old value of the group before the change.
newValue
The new value of the group after the change.
The instance of the RadioGroup .
public RadioGroup<T> triggerClearListeners(T oldValue)
oldValue
The old value of the group before the clear action.
The instance of the RadioGroup .
public String getType()
A string representation of the form element type, which is "RadioGroup".
public RadioGroup<T> withValue(T value)
value
The value to set for the radio group.
The instance of the RadioGroup .
public RadioGroup<T> withValue(T value, boolean silent)
value
The value to set for the radio group.
silent
A boolean flag indicating if the check action should trigger events.
The instance of the RadioGroup .
public RadioGroup<T> vertical()
The instance of the RadioGroup .
public RadioGroup<T> horizontal()
The instance of the RadioGroup .
public RadioGroup<T> vertical(boolean vertical)
vertical
A boolean indicating if the radio buttons should be arranged vertically.
The instance of the RadioGroup .
public List<Radio<? extends T>> getRadios()
A list of radio buttons.
public RadioGroup<T> withRadios(ChildHandler<RadioGroup<T>, List<Radio<? extends T>>> handler)
handler
A handler to apply changes to the list of radio buttons.
The instance of the RadioGroup .
public boolean isSelected()
A boolean indicating if a radio button is selected.
public T getValue()
The value of the selected radio button, or null if no button is selected.
public boolean isEmpty()
true if the group has no selected radio button, otherwise false .
public boolean isEmptyIgnoreSpaces()
true if the group has no selected radio button, otherwise false .
public RadioGroup<T> clear()
public String getName()
The name attribute of the radio group.
public RadioGroup<T> setName(String name)
name
The new name attribute to set.
The instance of the RadioGroup .
public RadioGroup<T> enable()
public RadioGroup<T> disable()
public boolean isEnabled()
true if all radio buttons are enabled, otherwise false .
public void setValue(Radio<T> value)
value
The value to be set.
public void setValue(T value, boolean silent)
value
The value to be set.
silent
If true, change listeners will not be notified.
public Radio<? extends T> getSelectedRadio()
The selected radio button, or null if none is selected.
public AutoValidator createAutoValidator(ApplyFunction autoValidate)
autoValidate
A function to apply the auto-validation logic.
An instance of AutoValidator for the radio group.
public void Radio(T value, String label)
value
The value associated with the radio button.
label
The label text for the radio button.
public void Radio(T value)
value
The value associated with the radio button.
public static Radio<E> create(E value, String label)
E
The type of value associated with the radio button.
value
The value associated with the radio button.
label
The label text for the radio button.
A new Radio instance.
public static Radio<E> create(E value)
E
The type of value associated with the radio button.
value
The value associated with the radio button.
A new Radio instance.
public String getType()
The type of the radio button input, which is "radio".
public Radio<T> check()
This `Radio` instance.
public Radio<T> uncheck()
This `Radio` instance.
public Radio<T> check(boolean silent)
silent
If true, change listener events will not be triggered.
This `Radio` instance.
public Radio<T> uncheck(boolean silent)
silent
If true, change listener events will not be triggered.
This `Radio` instance.
public Radio<T> toggleChecked(boolean silent)
silent
If true, change listener events will not be triggered.
This `Radio` instance.
public Radio<T> toggleChecked(boolean checkedState, boolean silent)
checkedState
The desired checked state.
silent
If true, change listener events will not be triggered.
This `Radio` instance.
public Radio<T> toggleChecked()
This `Radio` instance.
public boolean isChecked()
True if the radio button is checked, false otherwise.
public HTMLDivElement element()
The DOM element of this radio button.
public Radio<T> withValue(T value)
value
The value to set.
This `Radio` instance.
public Radio<T> withValue(T value, boolean silent)
value
The value to set.
silent
If `true`, change listeners won't be triggered.
This `Radio` instance.
public void setValue(T value)
value
The value to set.
public T getValue()
The current value of the radio button.
public Radio<T> setLabel(String label)
label
The label text to set.
This `Radio` instance.
public Radio<T> setLabel(SafeHtml safeHtml)
safeHtml
The SafeHtml content to set as the label.
This `Radio` instance.
public Radio<T> setLabel(Node node)
node
The DOM Node element to set as the label.
This `Radio` instance.
public Radio<T> setLabel(IsElement<?> element)
element
The IsElement instance whose element will be set as the label.
This `Radio` instance.
public String getLabel()
The text content of the radio button's label.
public Radio<T> enable()
This `Radio` instance.
public Radio<T> disable()
This `Radio` instance.
public String getHelperText()
The helper text.
public Radio<T> setHelperText(String text)
text
The helper text to set.
This `Radio` instance.
public boolean isEnabled()
`true` if the radio button is enabled, `false` otherwise.
public DominoElement<HTMLInputElement> getInputElement()
The input element.
public String getStringValue()
The string representation of the value.
public Radio<T> focus()
This `Radio` instance.
public Radio<T> unfocus()
This `Radio` instance.
public boolean isFocused()
`true` if the radio button is focused, `false` otherwise.
public Radio<T> labelForId(String id)
id
The `id` to associate with the label.
This `Radio` instance.
public Radio<T> pauseChangeListeners()
This `Radio` instance.
public Radio<T> resumeChangeListeners()
This `Radio` instance.
public Radio<T> togglePauseChangeListeners(boolean toggle)
toggle
`true` to pause change listeners, `false` to resume.
This `Radio` instance.
public Set<ChangeListener<? super Boolean>> getChangeListeners()
The set of change listeners.
public boolean isChangeListenersPaused()
`true` if change listeners are paused, `false` otherwise.
public Radio<T> triggerChangeListeners(Boolean oldValue, Boolean newValue)
oldValue
The old value.
newValue
The new value.
This `Radio` instance.
public DivElement getFieldInput()
The field input element.
public LabelElement getLabelElement()
The label element.
public SmallElement getNoteElement()
The note element.
public RadioGroup<? super T> getRadioGroup()
The radio group.
public T withFieldInput(ChildHandler<Radio<T>, DivElement> handler)
handler
The child handler for the field input element.
This `Radio` instance.
public T withLabelElement(ChildHandler<Radio<T>, LabelElement> handler)
handler
The child handler for the label element.
This `Radio` instance.
public T withNoteElement(ChildHandler<Radio<T>, SmallElement> handler)
handler
The child handler for the note element.
This `Radio` instance.
public T withRadioGroup(ChildHandler<Radio<T>, RadioGroup<? super T>> handler)
handler
The child handler for the radio group.
This `Radio` instance.