Class ContentModule

All Implemented Interfaces:
Component, Editable<ContentModule>

public class ContentModule extends Module implements Editable<ContentModule>
Editable module for rendering text or custom content blocks.

Contract: when customContent is set it takes precedence; otherwise content is rendered as Markdown by default or as escaped text when markdown is disabled.

Mutability and thread-safety: mutable and not thread-safe. Edit flows mutate the same instance and call rebuildContent() to satisfy module build-once lifecycle semantics; mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • ContentModule

      public ContentModule()
      Creates an empty content module.
  • Method Details

    • create

      public static ContentModule create()
      Creates a new module instance.
    • withContent

      public ContentModule withContent(String content)
      Sets text/markdown source content.
    • withCustomContent

      public ContentModule withCustomContent(Component content)
      Sets explicit custom content and bypasses text rendering when present.
    • disableMarkdown

      public ContentModule disableMarkdown()
      Disables Markdown rendering and renders content as escaped text.
    • withTitle

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

      public ContentModule 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
    • buildEditView

      public Component buildEditView()
      Builds the main-property edit view for this module.
      Specified by:
      buildEditView in interface Editable<ContentModule>
      Returns:
      component containing form controls
    • applyEdits

      public ContentModule applyEdits(Map<String,String> formData)
      Applies form data to this module instance.

      Side effect: mutates this module. Implementations should rebuild cached/built structure when required by module lifecycle semantics.

      Specified by:
      applyEdits in interface Editable<ContentModule>
      Parameters:
      formData - form field name to value map
      Returns:
      this module instance
    • validate

      public ValidationResult validate(Map<String,String> formData)
      Validates form data before mutation.
      Specified by:
      validate in interface Editable<ContentModule>
      Parameters:
      formData - form field name to value map
      Returns:
      validation result; default is success