Class FormModule

All Implemented Interfaces:
Component

public class FormModule extends Module
Module wrapper for composing and rendering a Form.

Contract: when withSubmitUrl(String) is set, it is applied as hx-post on the wrapped form during build.

Mutability and thread-safety: mutable and not thread-safe. Form fields are accumulated on this instance; mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • FormModule

      public FormModule()
      Creates a module with an empty form.
  • Method Details

    • create

      public static FormModule create()
      Creates a new module instance.
    • withSubmitUrl

      public FormModule withSubmitUrl(String url)
      Sets an application-controlled or separately endpoint-validated submit URL, applied as hx-post during build. Encoding is not scheme/destination validation, authorization, or CSRF.
    • withDescription

      public FormModule withDescription(String description)
      Sets optional descriptive text rendered above the form.
    • addField

      public FormModule addField(String label, Component input)
      Appends a labeled field to the wrapped form.
    • withForm

      public FormModule withForm(Form form)
      Replaces the wrapped form component.
    • withTitle

      public FormModule withTitle(String title)
      Description copied from class: Module
      Sets optional title consumed by Module.buildContent() implementations.
      Overrides:
      withTitle in class Module
    • withModuleId

      public FormModule withModuleId(String moduleId)
      Description copied from class: Module
      Sets module id and synchronizes the underlying id attribute.
      Overrides:
      withModuleId in class Module
    • buildContent

      protected void buildContent()
      Description copied from class: Module
      Composes module structure.

      Called at most once by Module.build() unless Module.rebuildContent() is invoked. Do not rely on this method for per-request mutation.

      Specified by:
      buildContent in class Module