Class Modal
java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.components.display.Modal
- All Implemented Interfaces:
Component
Backdrop-based modal renderer with configurable close behavior.
Mutable and not thread-safe. Configure and render within a request-scoped lifecycle. For reuse, stop mutating shared instances and render stable structures with per-request context data.
Load the framework JavaScript for focus entry/containment, close actions and focus restoration
on direct or HTMX insertion. The container is a named modal dialog; untitled dialogs use
Dialog as their accessible name without adding a visible header.
Security boundary: withModalId(String) validates generated identifiers.
Body/footer components are rendered with the supplied context.
-
Field Summary
Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Method Summary
Modifier and TypeMethodDescriptioncloseOnBackdrop(boolean enabled) Toggles close-on-backdrop behavior.closeOnEscape(boolean enabled) Toggles close-on-escape behavior.static Modalcreate()Creates a new modal instance.render()Ensures modal markup rendering is identical for context-aware parent render paths.render(RenderContext context) Renders complete modal/backdrop markup with configured behavior metadata and content.showCloseButton(boolean show) Toggles close button rendering in modal header.Sets modal body component.withFooter(Component footer) Sets modal footer component.withModalId(String modalId) Sets backdrop id and the prefix used for the dialog title id.Sets modal title text.Methods inherited from class HtmlTag
addClass, addStyle, addTrustedStyle, getChildrenStream, getId, hxDelete, hxGet, hxInclude, hxPatch, hxPost, hxPushUrl, hxPut, hxScrollTargetTop, hxSwap, hxTarget, hxTrigger, withAttribute, withChild, withClass, withId, withInnerText, withInnerText, withMaxWidth, withMinWidth, withUnsafeHtml, withWidth
-
Method Details
-
create
-
withModalId
Sets backdrop id and the prefix used for the dialog title id.- Parameters:
modalId- id matching^[a-zA-Z][a-zA-Z0-9_-]*$- Returns:
- this modal
- Throws:
IllegalArgumentException- when id format is invalid
-
withTitle
-
withBody
-
closeOnBackdrop
Toggles close-on-backdrop behavior.- Parameters:
enabled- true to enable backdrop click to close- Returns:
- this modal
-
closeOnEscape
Toggles close-on-escape behavior.- Parameters:
enabled- true to enable ESC key to close- Returns:
- this modal
-
showCloseButton
Toggles close button rendering in modal header.- Parameters:
show- true to show close button- Returns:
- this modal
-
render
Renders complete modal/backdrop markup with configured behavior metadata and content. -
render
Ensures modal markup rendering is identical for context-aware parent render paths.- Returns:
- modal HTML
-