Class Checkbox

All Implemented Interfaces:
Component

public class Checkbox extends Div
Checkbox wrapper with optional label.

Mutable and not thread-safe. Builder-style methods update the same input/label state. Mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • Checkbox

      public Checkbox(String name, String value)
      Creates a checkbox control.
      Parameters:
      name - input name
      value - input value
  • Method Details

    • create

      public static Checkbox create(String name, String value)
      Creates a checkbox control.
      Parameters:
      name - input name
      value - input value
      Returns:
      new checkbox
    • withId

      public Checkbox withId(String id)
      Sets checkbox input id.
      Overrides:
      withId in class Div
      Parameters:
      id - input id
      Returns:
      this checkbox
    • getId

      public String getId()
      Description copied from class: HtmlTag
      Returns the currently assigned id value.
      Overrides:
      getId in class HtmlTag
    • withLabel

      public Checkbox withLabel(String labelText)
      Creates and attaches a label linked to this checkbox.

      Preserves an explicit input id, or generates one when absent.

      Parameters:
      labelText - label text
      Returns:
      this checkbox
    • checked

      public Checkbox checked()
      Marks checkbox as checked.
      Returns:
      this checkbox
    • required

      public Checkbox required()
      Marks checkbox as required.
      Returns:
      this checkbox
    • disabled

      public Checkbox disabled()
      Marks checkbox as disabled.
      Returns:
      this checkbox
    • getChildrenStream

      protected Stream<Component> getChildrenStream()
      Renders checkbox input first, optional label second, then inherited children.
      Overrides:
      getChildrenStream in class HtmlTag
      Returns:
      child stream