Class EditModalBuilder

java.lang.Object
io.mindspice.simplypages.editing.EditModalBuilder

public class EditModalBuilder extends Object
Builds standardized edit modals for module property and child-edit flows.

Contract: provide an explicit editView, an editable, or both. An explicit view supplies the property form; otherwise the builder uses editable.buildEditView(). When supplied, editable also provides child handles. Save actions post to saveUrl; child actions are emitted only when corresponding URL templates are configured.

Mutability and thread-safety: mutable and not thread-safe. Configure and build within a single request flow.

  • Method Details

    • create

      public static EditModalBuilder create()
      Creates a new builder instance.
    • withTitle

      public EditModalBuilder withTitle(String title)
      Sets modal title text.
    • withModuleId

      public EditModalBuilder withModuleId(String moduleId)
      Sets the module identifier used by callers for endpoint construction.
    • withEditView

      public EditModalBuilder withEditView(Component editView)
      Sets pre-built edit view content for main module properties.
    • withEditable

      public EditModalBuilder withEditable(Editable<?> editable)
      Sets editable module adapter used to source edit view and child handles.
    • withSaveUrl

      public EditModalBuilder withSaveUrl(String saveUrl)
      Sets the complete caller URL used by Save; no template substitution or URL encoding.
    • withDeleteUrl

      public EditModalBuilder withDeleteUrl(String deleteUrl)
      Sets the complete caller URL used by Delete; no template substitution or URL encoding.
    • withChildEditUrl

      public EditModalBuilder withChildEditUrl(String childEditUrl)
      Sets the child-edit URL template; null disables the action. Only {id} is supported, as a whole path segment or whole query value. Repeated/omitted tokens and fixed URLs are allowed; literal URL text is preserved. In browser-relevant structure, token-bearing absolute URLs require scheme://nonempty-literal-authority; protocol-relative, root-relative, relative-path and query-only references are supported. Placement is also checked after browser-style control/space and path-backslash handling, without rewriting the output. Scheme shorthands, empty authorities and opaque templated URLs are unsupported; fixed URLs do not acquire structural validation.

      When a child action is built, its raw id is UTF-8 percent-encoded without trimming, normalization or decoding. Used ids must be non-null, nonempty, nonblank, not exactly . or .., and valid UTF-16. Literal percent signs are encoded too. No id validation occurs for disabled actions, empty child lists or omitted tokens. Legacy partial-segment, query-key, authority and fragment token placements are rejected.

      Parameters:
      childEditUrl - caller-owned template or null
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for unsupported tokens or token placements
    • withChildDeleteUrl

      public EditModalBuilder withChildDeleteUrl(String childDeleteUrl)
      Sets the child-delete URL template; null disables the action. Uses the same token placement, raw-id encoding and build-time id validation as withChildEditUrl(String).
      Parameters:
      childDeleteUrl - caller-owned template or null
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for unsupported tokens or token placements
    • hideDelete

      public EditModalBuilder hideDelete()
      Hides the delete action in the modal footer.
    • withPageContainerId

      public EditModalBuilder withPageContainerId(String pageContainerId)
      Sets page container id targeted by delete operations.
      Throws:
      IllegalArgumentException - when id is null or fails identifier validation
    • withModalContainerId

      public EditModalBuilder withModalContainerId(String modalContainerId)
      Sets modal container id targeted by modal updates.
      Throws:
      IllegalArgumentException - when id is null or fails identifier validation
    • build

      public Modal build()
      Builds the configured modal.
      Throws:
      IllegalStateException - when required edit source or save URL is missing