Class RadioGroup

All Implemented Interfaces:
Component

public class RadioGroup extends Div
Radio button group with shared input name and radiogroup role.

Form.addField(String, Component) names the group from its visible caption without changing option labels. Standalone groups need an application-supplied accessible name through the existing aria-label or aria-labelledby attribute APIs; the submission name is not used as an accessible name.

Mutable and not thread-safe. Options are accumulated in-memory and rendered in insertion order. Mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • RadioGroup

      public RadioGroup(String name)
      Creates a radio group.
      Parameters:
      name - shared radio input name
  • Method Details

    • create

      public static RadioGroup create(String name)
      Creates a radio group.
      Parameters:
      name - shared radio input name
      Returns:
      new radio group
    • addOption

      public RadioGroup addOption(String value, String label)
      Appends one option.
      Parameters:
      value - option value
      label - option label
      Returns:
      this group
    • withSelectedValue

      public RadioGroup withSelectedValue(String value)
      Sets selected option value.
      Parameters:
      value - value matched during render
      Returns:
      this group
    • required

      public RadioGroup required()
      Marks current and subsequently added options as required.
      Returns:
      this group
    • inline

      public RadioGroup inline()
      Adds radio-inline class.
      Returns:
      this group
    • getChildrenStream

      protected Stream<Component> getChildrenStream()
      Builds radio-option wrappers and appends inherited children.
      Overrides:
      getChildrenStream in class HtmlTag
      Returns:
      child stream