Class EditableRow

java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.editing.EditableRow
All Implemented Interfaces:
Component

public class EditableRow extends HtmlTag
Composes a supplied row with a separate row of registered editable modules and add-module controls.

The supplied row retains its own attributes, content and renderer. Registrations are independent content, not edits to that row; callers must avoid registering content already present there.

Lifecycle: module list is mutable via configuration methods; the registered-module row/column structure is rebuilt on each render call with equal-width columns (fill columns above twelve).

Rendering uses a temporary tag and does not change stored wrapper attributes or children. Generic inherited children remain stored but are not emitted; only the supplied row and generated registration/add-control composition is emitted. Templates retain this renderer live. Finish mutable configuration before sharing; supplied custom renderers, modules and request contexts retain their own lifecycle and sharing obligations.

  • Method Details

    • wrap

      public static EditableRow wrap(Row row, String rowId, String pageId)
      Creates a wrapper containing the supplied row, then a separate registered-module row and an optional add-module control.

      A non-null row is rendered once per wrapper render with the same render context, including custom HtmlTag.render(RenderContext) overrides and rendering through a template. This wrapper does not copy or mutate the supplied row's structure. Its id, classes and other attributes remain on the supplied row, distinct from the outer wrapper's attributes.

      Modules registered with addEditableModule(Module, String) belong only to the separate generated row. No merging or deduplication occurs; callers must not register content already present in the supplied row. Registration still assigns the supplied module's module id.

      Parameters:
      row - independent source row; an empty row is retained, while null omits it
      rowId - identifier used for the outer wrapper id and add-module endpoint
      pageId - identifier used for generated editing endpoints
      Returns:
      a new mutable, non-thread-safe wrapper
    • withMaxModules

      public EditableRow withMaxModules(int max)
      Sets max registrations allowed in the generated row; source-row children do not count.
      Throws:
      IllegalArgumentException - when max < 1
    • withModuleEditUrlTemplate

      public EditableRow withModuleEditUrlTemplate(String template)
      Sets the module-edit URL template (default /api/pages/{pageId}/modules/{moduleId}/edit). Supports {pageId}, {rowId} and {moduleId} only as whole path segments or whole query values; repeated/omitted tokens and fixed URLs are allowed. 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.

      Templates are validated here; raw ids are validated and UTF-8 percent-encoded only when interpolated during render. Used ids must be non-null, nonempty, nonblank, not exactly . or .., and valid UTF-16. No trimming, normalization or decoding occurs; literal percent signs are encoded. Unused ids and DOM ids are unaffected. Literal URL text is preserved. Applications own routing, server decoding, authorization and CSRF.

      Parameters:
      template - caller-owned module-edit URL template
      Returns:
      this row
      Throws:
      IllegalArgumentException - for null templates, unsupported tokens or token placements
    • withModuleDeleteUrlTemplate

      public EditableRow withModuleDeleteUrlTemplate(String template)
      Sets the module-delete URL template (default /api/pages/{pageId}/modules/{moduleId}/delete). Supports {pageId}, {rowId} and {moduleId} with the placement, encoding and render-time id validation described in withModuleEditUrlTemplate(String). Configuring this operation does not change the edit or add-form template.
      Parameters:
      template - caller-owned module-delete URL template
      Returns:
      this row
      Throws:
      IllegalArgumentException - for null templates, unsupported tokens or token placements
    • withAddModuleFormUrlTemplate

      public EditableRow withAddModuleFormUrlTemplate(String template)
      Sets the add-module-form URL template (default /api/pages/{pageId}/rows/{rowId}/add-module-form). Supports only {pageId} and {rowId}, using the placement, encoding and render-time id validation described in withModuleEditUrlTemplate(String). This template is expanded only when the add control is eligible to render.
      Parameters:
      template - caller-owned add-form URL template
      Returns:
      this row
      Throws:
      IllegalArgumentException - for null templates, unsupported tokens or token placements
    • withEditMode

      public EditableRow withEditMode(EditMode mode)
      Sets edit mode applied to generated EditableModule wrappers.
    • withCanAddModule

      public EditableRow withCanAddModule(boolean canAddModule)
      Sets whether the add-module control is rendered.
    • addEditableModule

      public EditableRow addEditableModule(Module module, String moduleId)
      Adds independent content to the generated row, wrapped at render time, and assigns its module id. This does not make existing source-row content editable or deduplicate it.
      Throws:
      IllegalStateException - when module limit is reached
    • render

      public String render(RenderContext context)
      Renders the supplied row, then rebuilt editable-module columns and an optional add control.
      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()
      Description copied from interface: Component
      Renders this component with an empty context.
      Returns:
      rendered HTML for this component