Class RegionTable

java.lang.Object
org.apache.juneau.console.views.RegionTable

public class RegionTable extends Object
Builds the server-rendered delivery tree for a RegionDef — an empty data-juneau-region container plus one sidecar per host carrying every region descriptor that host declares.
The container carries identity; the sidecar carries configuration:

The container is deliberately empty and deliberately attribute-only — id, type, and the handshake stamp and nothing else. Configuration (the populator name, dataUrl, params, renderer, lazy, refreshMs, the field catalog) rides the sidecar, for the same reason PAGE_META does: an attribute per descriptor key would put author strings in attribute position on every host, and a JSON envelope is the shape the client already parses. The attributes are exactly what the runtime scans for, mirroring the existing data-juneau-page / data-juneau-view / data-juneau-card markers.

One sidecar per host, not per region. One <script> per card in a twelve-card grid is twelve parses; the existing pattern is one sidecar per view / page / header / bar, and this follows it.

Two sidecar forms, and why the second exists:

sidecar(String, List) stamps a document-unique HTML id, for an ordinary once-per-response host (a page, a card grid). detailSidecar(List) ships id-less and is found by attribute instead, because a row-detail sidecar lives inside the <template data-juneau-row-detail> that is cloned per expanded row — a stamped id would collide across every open panel. This is exactly the split BarSlot already makes, for the same reason.

Since:
10.0.0
  • Field Details

    • REGION_ATTR

      public static final String REGION_ATTR
      Marker attribute carrying a region's own id: data-juneau-region.
      See Also:
    • REGION_TYPE_ATTR

      public static final String REGION_TYPE_ATTR
      Attribute carrying the region's type (RegionDef.TYPE_ROW_DETAIL and friends).
      See Also:
    • REGION_POPULATE_ATTR

      public static final String REGION_POPULATE_ATTR
      Attribute carrying the region's populator name: data-juneau-region-populate.

      This attribute is how the populator name reaches the runtime at all, so omitting it fails silently in the worst possible way. juneau-regions.js's mintRegion reads the name with el.getAttribute("data-juneau-region-populate"); a container without it yields null, which resolves to the default populator rather than to an error. So a page whose author registered a named populate would paint the framework default instead, with no console error, no error pane, and a rendered result that looks plausible — the author's populate simply never runs.

      Deliberately an attribute rather than a sidecar member, unlike most of a region's configuration. The name is needed to decide which function to call at mint time, before any per-host sidecar has been matched to this container; identity-and-dispatch data rides the element, and everything else rides the sidecar.

      See Also:
    • REGION_CONTRACT_ATTR

      public static final String REGION_CONTRACT_ATTR
      Attribute carrying RegionDef.CONTRACT_VERSION on the region container (the per-host handshake stamp).
      See Also:
    • REGION_CSRF_ATTR

      public static final String REGION_CSRF_ATTR
      Attribute carrying the enclosing response's CSRF token on a region host that is not a <table> — deliberately ViewTable.CSRF_ATTR, the same attribute the view table already stamps, not a region-specific second name.

      A region that performs a write has no token source of its own: the existing stamp lives on the view <table>, and a card-body or tab-body region is not beneath one. Rather than mint a second token or teach every populate to hunt for the table's, the host that emits a non-table region stamps the same per-response token it already holds.

      Reusing the existing attribute name is what makes this cost zero client change: ctx.write(...) already resolves its token with el.closest("[data-juneau-csrf]"), so a region container carrying this attribute is found by the code that is already there. A region-specific name would have required teaching that resolver a second selector, and the two would then have been able to disagree.

      A row-detail region is beneath the view table and therefore does not carry this attribute: it inherits the table's by closest(...), and a second stamp on the same subtree is the hazard rather than the fix for it.

      See Also:
    • REGION_DECLARED_ATTR

      public static final String REGION_DECLARED_ATTR
      Attribute carrying the region's own contract descriptor (its params included) as JSON, for a region placed outside a sidecar-bearing host.

      Stamped by of(RegionDef, String) only when the region declares params; the region runtime reads it as the placeholder's declared descriptor.

      See Also:
    • REGION_META_ATTR

      public static final String REGION_META_ATTR
      Attribute the id-less detailSidecar(List) form is found by.
      See Also:
    • SIDECAR_ID_PREFIX

      public static final String SIDECAR_ID_PREFIX
      HTML id prefix for the sidecar(String, List) form.
      See Also:
    • REGION_CLASS

      public static final String REGION_CLASS
      The class on every region container.
      See Also:
  • Method Details

    • of

      public static Div of(RegionDef region)
      Emits one empty region container.

      In-table region HTML (ViewTable's detail template). Page slots: author HTML plus JuneauViews.regions.mount({ id: populatorName }). Not @Deprecated.

      Parameters:
      region - The region. Must not be null.
      Returns:
      An empty <div class='juneau-region'> carrying identity, type and the handshake stamp.
    • of

      public static Div of(RegionDef region, String csrfToken)
      Emits one empty region container, optionally carrying the non-table host's CSRF stamp.

      In-table region HTML (ViewTable's detail template). Page slots: author HTML plus JuneauViews.regions.mount({ id: populatorName }). Not @Deprecated.

      Parameters:
      region - The region. Must not be null.
      csrfToken - The enclosing response's token for a non-table host, or null to omit the stamp — which is the correct choice for a row-detail region, since it sits beneath the view table's own stamp and must not carry a second one.
      Returns:
      An empty <div class='juneau-region'>.
    • sidecar

      public static Script sidecar(String hostId, List<RegionDef> regions)
      Emits the per-host sidecar with a document-unique HTML id.

      No in-table keeper in this module's production emit path; leftover page-slot callers migrate to JuneauViews.regions.mount. Not @Deprecated.

      Parameters:
      hostId - The host's own id (a page id, a card-grid id); the sidecar's id is SIDECAR_ID_PREFIX + this. Must not be null or blank.
      regions - Every region this host declares, in emit order. Must not be null or empty.
      Returns:
      The <script type='application/json'> sidecar.
    • detailSidecar

      public static Script detailSidecar(List<RegionDef> regions)
      Emits the id-less, attribute-found sidecar for a host whose subtree is cloned per row.

      See this class's Javadoc: a row-detail sidecar lives inside the cloned <template data-juneau-row-detail>, so a stamped id would collide across every open panel.

      In-table region HTML (ViewTable's detail template). Not @Deprecated.

      Parameters:
      regions - Every region this host declares, in emit order. Must not be null or empty.
      Returns:
      The <script type='application/json'> sidecar, carrying REGION_META_ATTR.
    • buildMeta

      public static Map<String,Object> buildMeta(List<RegionDef> regions)
      Builds the sidecar envelope: the contract version once, then one descriptor per region in emit order.
      Parameters:
      regions - The regions, in emit order. Must not be null or empty.
      Returns:
      An ordered Map ready for Json.of(...).