Class ContentModule
java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.core.Module
io.mindspice.simplypages.modules.ContentModule
- All Implemented Interfaces:
Component, 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.
-
Field Summary
Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyEdits(Map<String, String> formData) Applies form data to this module instance.protected voidComposes module structure.Builds the main-property edit view for this module.static ContentModulecreate()Creates a new module instance.Disables Markdown rendering and renders content as escaped text.Validates form data before mutation.withContent(String content) Sets text/markdown source content.withCustomContent(Component content) Sets explicit custom content and bypasses text rendering when present.withModuleId(String moduleId) Sets module id and synchronizes the underlyingidattribute.Sets optional title consumed byModule.buildContent()implementations.Methods inherited from class Module
build, getModuleId, getTitle, invalidateContent, rebuildContent, render, render, withClass, withMaxWidth, withMinWidth, withWidthMethods 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, withUnsafeHtmlMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Editable
getEditableChildren
-
Constructor Details
-
ContentModule
public ContentModule()Creates an empty content module.
-
-
Method Details
-
create
Creates a new module instance. -
withContent
Sets text/markdown source content. -
withCustomContent
Sets explicit custom content and bypasses text rendering when present. -
disableMarkdown
Disables Markdown rendering and renders content as escaped text. -
withTitle
Description copied from class:ModuleSets optional title consumed byModule.buildContent()implementations. -
withModuleId
Description copied from class:ModuleSets module id and synchronizes the underlyingidattribute.- Overrides:
withModuleIdin classModule
-
buildContent
protected void buildContent()Description copied from class:ModuleComposes module structure.Called at most once by
Module.build()unlessModule.rebuildContent()is invoked. Do not rely on this method for per-request mutation.- Specified by:
buildContentin classModule
-
buildEditView
Builds the main-property edit view for this module.- Specified by:
buildEditViewin interfaceEditable<ContentModule>- Returns:
- component containing form controls
-
applyEdits
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:
applyEditsin interfaceEditable<ContentModule>- Parameters:
formData- form field name to value map- Returns:
- this module instance
-
validate
Validates form data before mutation.- Specified by:
validatein interfaceEditable<ContentModule>- Parameters:
formData- form field name to value map- Returns:
- validation result; default is success
-