Class Module

java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.core.Module
All Implemented Interfaces:
Component
Direct Known Subclasses:
AccordionModule, CalloutModule, ChatModule, ComparisonModule, ContentModule, DataModule, DynamicCardModule, DynamicListModule, DynamicTableModule, FormModule, GalleryModule, HeroModule, QuoteModule, RichContentModule, SimpleListModule, StatsModule, TabsModule, TimelineModule

public abstract class Module extends HtmlTag
Base class for high-level composed components with build-once lifecycle semantics.

Lifecycle contract:

- callers configure mutable fields through fluent methods

- build() invokes buildContent() once per instance

- render(RenderContext) guarantees build before rendering

Dynamic-data boundary: buildContent() should compose structure only. Per-request dynamic values must flow through SlotKey and Slot.

Mutability/thread-safety: mutable and not thread-safe while being configured. Mutate module state in a request-scoped flow; for reuse, stop mutating after composition/build and render via a stable structure (typically Template) with per-request RenderContext values.

  • Field Details

    • moduleId

      protected String moduleId
      Optional module id mirrored to HTML id attribute.
    • title

      protected String title
      Optional title consumed by subclass build logic.
  • Constructor Details

    • Module

      protected Module(String tagName)
      Creates a module backed by the provided container tag.
  • Method Details

    • withModuleId

      public Module withModuleId(String moduleId)
      Sets module id and synchronizes the underlying id attribute.
    • getModuleId

      public String getModuleId()
      Returns the configured module id, or null.
    • getTitle

      public String getTitle()
      Returns the configured module title, or null.
    • withTitle

      public Module withTitle(String title)
      Sets optional title consumed by buildContent() implementations.
    • withClass

      public Module withClass(String className)
      Adds a class token; module base class is still enforced by build lifecycle.
      Overrides:
      withClass in class HtmlTag
    • withWidth

      @Deprecated public Module withWidth(String width)
      Deprecated.
      use layout containers to size modules
      Disallowed on modules; width must be controlled by layout containers.
      Overrides:
      withWidth in class HtmlTag
      Throws:
      UnsupportedOperationException - always
    • withMaxWidth

      @Deprecated public Module withMaxWidth(String maxWidth)
      Deprecated.
      use layout containers to size modules
      Disallowed on modules; max-width must be controlled by layout containers.
      Overrides:
      withMaxWidth in class HtmlTag
      Throws:
      UnsupportedOperationException - always
    • withMinWidth

      @Deprecated public Module withMinWidth(String minWidth)
      Deprecated.
      use layout containers to size modules
      Disallowed on modules; min-width must be controlled by layout containers.
      Overrides:
      withMinWidth in class HtmlTag
      Throws:
      UnsupportedOperationException - always
    • buildContent

      protected abstract void buildContent()
      Composes module structure.

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

    • rebuildContent

      protected void rebuildContent()
      Replaces built structure immediately, restoring entry-state children, attributes, cached id and build status if composition throws a RuntimeException or Error.

      The snapshot is shallow and includes caller changes made before this call. It does not restore module id, title, text/slots, subclass fields, descendants or external effects. A previously built module remains built after failure; a never-built module remains retryable.

    • invalidateContent

      protected void invalidateContent()
      Clears built child structure so the next render rebuilds from current mutable fields.

      Use from mutators that remain supported after a module has already been rendered.

    • build

      public Module build()
      Ensures module structure is built once. Failed initial builds restore shallow child and attribute collections and cached id so a later call can retry. Subclasses own rollback of all other state and side effects; see rebuildContent() for the explicit rebuild boundary.
    • render

      public String render(RenderContext context)
      Builds if needed, then delegates rendering to HtmlTag.
      Specified by:
      render in interface Component
      Overrides:
      render in class HtmlTag
      Parameters:
      context - context used for slot resolution and render policy
      Returns:
      rendered HTML for this component
    • render

      public String render()
      Renders with RenderContext.empty().
      Returns:
      rendered HTML for this component