Class 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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected StringOptional module id mirrored to HTMLidattribute.protected StringOptional title consumed by subclass build logic.Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Ensures module structure is built once.protected abstract voidComposes module structure.Returns the configured module id, ornull.getTitle()Returns the configured module title, ornull.protected voidClears built child structure so the next render rebuilds from current mutable fields.protected voidReplaces built structure immediately, restoring entry-state children, attributes, cached id and build status if composition throws aRuntimeExceptionorError.render()Renders withRenderContext.empty().render(RenderContext context) Builds if needed, then delegates rendering toHtmlTag.Adds a class token;modulebase class is still enforced by build lifecycle.withMaxWidth(String maxWidth) Deprecated.use layout containers to size moduleswithMinWidth(String minWidth) Deprecated.use layout containers to size moduleswithModuleId(String moduleId) Sets module id and synchronizes the underlyingidattribute.Sets optional title consumed bybuildContent()implementations.Deprecated.use layout containers to size modulesMethods inherited from class HtmlTag
addClass, addStyle, addTrustedStyle, getChildrenStream, getId, hxDelete, hxGet, hxInclude, hxPatch, hxPost, hxPushUrl, hxPut, hxScrollTargetTop, hxSwap, hxTarget, hxTrigger, withAttribute, withChild, withId, withInnerText, withInnerText, withUnsafeHtml
-
Field Details
-
moduleId
Optional module id mirrored to HTMLidattribute. -
title
Optional title consumed by subclass build logic.
-
-
Constructor Details
-
Module
Creates a module backed by the provided container tag.
-
-
Method Details
-
withModuleId
-
getModuleId
Returns the configured module id, ornull. -
getTitle
Returns the configured module title, ornull. -
withTitle
Sets optional title consumed bybuildContent()implementations. -
withClass
-
withWidth
Deprecated.use layout containers to size modulesDisallowed on modules; width must be controlled by layout containers.- Overrides:
withWidthin classHtmlTag- Throws:
UnsupportedOperationException- always
-
withMaxWidth
Deprecated.use layout containers to size modulesDisallowed on modules; max-width must be controlled by layout containers.- Overrides:
withMaxWidthin classHtmlTag- Throws:
UnsupportedOperationException- always
-
withMinWidth
Deprecated.use layout containers to size modulesDisallowed on modules; min-width must be controlled by layout containers.- Overrides:
withMinWidthin classHtmlTag- Throws:
UnsupportedOperationException- always
-
buildContent
protected abstract void buildContent()Composes module structure.Called at most once by
build()unlessrebuildContent()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 aRuntimeExceptionorError.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
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; seerebuildContent()for the explicit rebuild boundary. -
render
-
render
Renders withRenderContext.empty().- Returns:
- rendered HTML for this component
-