Class RegionDef
populate rather than declared inline.
Beyond the identity/populator core, this bean also carries the declarative descriptor: a data source (dataUrl / params), an inline renderer (renderer),
lazy activation (lazy), a refresh interval (refreshMs), and a field/title projection
(fields / titleFields). A descriptor that omits populate resolves to the
Juneau-shipped declarative default (JuneauViews.regions.defaultPopulate), which reads exactly
this descriptor (via ctx.declared) and nothing else.
Mutability
Deliberately mutable, like Column and ViewDef (the same rule, stated here since this class
predates it): a RegionDef is a server-side authoring bean built up once via its public fields and
fluent setters while constructing a page, not an immutable value object. Callers must not
mutate one concurrently from more than one thread, and must not reuse one across requests unless every request
treats it as read-only after construction.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOne entry in the field catalog: a label, an optional named renderer and its meta, an optional href template, a paint format, a grid span, and per-field action-bar ids. -
Field Summary
FieldsModifier and TypeFieldDescriptionApp-approved populator names allowed onpopulatein addition toPopulatorAllowlist.BUILTIN_IDS.Populator-owned structured configuration.static final StringThe frozen contract version for the region envelope.A same-origin path from which the declarative default (andctx.fetchDeclared()) fetches this region's payload.The field catalog: labels, renderers, hrefs, spans and per-field action-bar ids, declared once per region rather than repeated per row/refresh.This region's own id, unique within its host.Whether this region's first populate is deferred until it becomes visible.static final longThe minimum honoredrefreshMs, in milliseconds.Author-declared request parameters, opaque to the framework as a payload (nothing routes or branches on their contents) but not opaque to the query-string serializer that appends them todataUrl.The name of the client populator to resolve viaJuneauViews.regions.resolve(name), ornull for the reserved declarative default ("default" , seePopulatorAllowlist.BUILTIN_IDS).The declared auto-refresh interval, in milliseconds, ornull for no polling.The name of theJuneauViews.helpersfunction the declarative default paints with, e.g.Chrome's declared title-key allowlist — the one descriptor field whose only reader is the framework's own title painter, never the populate (see the three-way partition; the declarative default's source must not reference this field).static final StringWire token for a card-body region.static final StringWire token for a row-detail region.static final StringWire token for a tab-body region.The rules that must all match for the whole region to render. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallowPopulators(String... value) Opts in app-approved populator names forpopulate, in addition toPopulatorAllowlist.BUILTIN_IDS.Sets the populator-owned structured configuration.static RegionDefCreates a region with the given id.Sets the same-origin data-fetch endpoint.booleanThe effectivelazyvalue once the per-region-type default is applied.fields(RegionDef.Field... value) Sets the field catalog.static booleanisSafeDetailEndpoint(String endpoint) Whetherendpointis a same-origin path template: no://, no//prefix, no scheme colon-before-slash, and no..path segments.lazy(boolean value) Sets whether this region's first populate is deferred until it becomes visible.Sets the author-declared request parameters from key/value pairs, preserving call order.Sets the author-declared request parameters.Sets the name of the client populator to resolve.refreshMs(long intervalMs) Declares that this region should be polled (re-fetched and re-populated) on the given interval.Sets the helper name the declarative default paints with.titleFields(String... value) Sets chrome's declared title-key allowlist.Serializes this descriptor to the compact JSON envelope thedata-juneau-region-contractsidecar attribute carries, hand-built (rather than reflected) so the key set, order, and each nestedRegionDef.Field's wire shape are exactly the ones the contract specifies.Sets this region's type.voidvalidate()Fail-closed bean validation.visibleWhen(VisibilityRule... rules) Hides this region unless every rule matches.
-
Field Details
-
CONTRACT_VERSION
The frozen contract version for the region envelope.Deliberately independent of
ViewsMixin.CONTRACT_VERSION: a region-contract revision must never force a view-sidecar bump, or vice-versa.- See Also:
-
TYPE_ROW_DETAIL
Wire token for a row-detail region.- See Also:
-
TYPE_CARD_BODY
Wire token for a card-body region.- See Also:
-
TYPE_TAB_BODY
Wire token for a tab-body region.- See Also:
-
MIN_REFRESH_MS
The minimum honoredrefreshMs, in milliseconds.A declared interval below this floor is clamped up to it rather than honored as configured — the same reasoning and the same shared floor as
SafePathTemplate.MIN_POLL_INTERVAL_MS.- See Also:
-
id
This region's own id, unique within its host. -
populate
The name of the client populator to resolve viaJuneauViews.regions.resolve(name), ornull for the reserved declarative default ("default" , seePopulatorAllowlist.BUILTIN_IDS).This is a name looked up in the client registry rather than an inline function for two reasons: an inline function cannot survive the JSON sidecar this envelope travels in, and a name — unlike an arbitrary function body — is the one shape a server-side allowlist (
PopulatorAllowlist) can meaningfully constrain at all. -
type
This region's type:TYPE_ROW_DETAIL,TYPE_CARD_BODY, orTYPE_TAB_BODY.Set by the enclosing host (a detail panel, a card, or a tab body) rather than by the region's own author in the common case; exposed here (rather than only in the sidecar) because
validate()needs it to enforce the type-scoped field-catalog rules — aTYPE_ROW_DETAILregion must carry nofields, and aTYPE_CARD_BODY/TYPE_TAB_BODYregion using the"field-grid"rendererunder the reserved default must carry at least one. -
dataUrl
A same-origin path from which the declarative default (andctx.fetchDeclared()) fetches this region's payload.null means "no declared fetch" — legal, and the normal state for a custom populator that fetches its own way or paints with no fetch at all.Validated with
isSafeDetailEndpoint(String)(same-origin, no scheme, no leading//, no..segment). -
params
Author-declared request parameters, opaque to the framework as a payload (nothing routes or branches on their contents) but not opaque to the query-string serializer that appends them todataUrl. Use aLinkedHashMap(or an equivalent ordered map) when key order matters to the endpoint: the serialization walksMap.entrySet()in the map's own iteration order. -
renderer
The name of theJuneauViews.helpersfunction the declarative default paints with, e.g."field-grid" .null when a custompopulatedoes its own painting. -
lazy
Whether this region's first populate is deferred until it becomes visible.null means "use the per-region-type default":false forTYPE_ROW_DETAILandTYPE_CARD_BODY,true forTYPE_TAB_BODY— seeeffectiveLazy(). -
refreshMs
The declared auto-refresh interval, in milliseconds, ornull for no polling.A value below
MIN_REFRESH_MSis silently clamped up to the floor rather than rejected. -
fields
The field catalog: labels, renderers, hrefs, spans and per-field action-bar ids, declared once per region rather than repeated per row/refresh. Projects ontoctx.declared.fields.Card and tab regions only. A
TYPE_ROW_DETAILregion's catalog is an author-declared JS literal handed straight tofieldGridclient-side; declaringfieldson aTYPE_ROW_DETAILregion failsvalidate(). -
titleFields
Chrome's declared title-key allowlist — the one descriptor field whose only reader is the framework's own title painter, never the populate (see the three-way partition; the declarative default's source must not reference this field). -
allowedPopulators
App-approved populator names allowed onpopulatein addition toPopulatorAllowlist.BUILTIN_IDS. Blank entries failvalidate().Opting a name in here is authoring discipline, not a security boundary — see
PopulatorAllowlist's class Javadoc. -
visibleWhen
The rules that must all match for the whole region to render.null or empty means always visible. SeeRowAction.visibleWhenfor the shared semantics and evaluation-map convention. -
config
Populator-owned structured configuration.null or empty means none.Unlike
params, nested maps and lists are allowed, and the value is never appended todataUrlnor sent back to the server: it reaches the client only asctx.declared.config. Its shape belongs to the populator that reads it (for exampleJobLogRegion);validate()only checks that it is JSON-serializable (string keys, no cycles).
-
-
Constructor Details
-
RegionDef
public RegionDef()
-
-
Method Details
-
create
Creates a region with the given id.The identity plus populator name. Page slots do not go through this factory — author HTML plus
JuneauViews.regions.mount({ id: populatorName }). Not@Deprecated.- Parameters:
id- This region's own id, unique within its host. Must not benull or blank.- Returns:
- A new
RegionDef.
-
populate
Sets the name of the client populator to resolve.- Parameters:
value- A populator name, ornull to use the reserved declarative default.- Returns:
- This object.
-
type
Sets this region's type.- Parameters:
value- One ofTYPE_ROW_DETAIL,TYPE_CARD_BODY,TYPE_TAB_BODY.- Returns:
- This object.
-
dataUrl
Sets the same-origin data-fetch endpoint.- Parameters:
value- The path. Must be a same-origin path template (no://, no leading//, no scheme colon-before-slash, no..segment) — enforced atvalidate().- Returns:
- This object.
-
params
Sets the author-declared request parameters.- Parameters:
value- The parameters. ALinkedHashMap(or equivalent ordered map) when key order matters.- Returns:
- This object.
-
params
Sets the author-declared request parameters from key/value pairs, preserving call order.- Parameters:
keyValuePairs- An even-lengthkey, value, key, value, ...sequence.- Returns:
- This object.
-
renderer
Sets the helper name the declarative default paints with.- Parameters:
value- AJuneauViews.helpersfunction name, e.g."field-grid" .- Returns:
- This object.
-
lazy
Sets whether this region's first populate is deferred until it becomes visible.- Parameters:
value-true /false , or leave unset (null ) for the per-region-type default.- Returns:
- This object.
-
refreshMs
Declares that this region should be polled (re-fetched and re-populated) on the given interval.A value below
MIN_REFRESH_MSis silently clamped up to the floor rather than rejected.- Parameters:
intervalMs- The desired polling interval, in milliseconds. Must be positive.- Returns:
- This object.
-
visibleWhen
Hides this region unless every rule matches.- Parameters:
rules- The rules; all must match. Replaces any rules set by an earlier call.- Returns:
- This object.
-
config
Sets the populator-owned structured configuration.- Parameters:
value- The configuration; seeconfig.- Returns:
- This object.
-
fields
Sets the field catalog.- Parameters:
value- The catalog, in declaration order. Card/tab regions only — seefields.- Returns:
- This object.
-
titleFields
Sets chrome's declared title-key allowlist.- Parameters:
value- The allowlisted keys.- Returns:
- This object.
-
allowPopulators
Opts in app-approved populator names forpopulate, in addition toPopulatorAllowlist.BUILTIN_IDS.- Parameters:
value- Populator names. Must not contain blank entries.- Returns:
- This object.
-
effectiveLazy
The effectivelazyvalue once the per-region-type default is applied.false forTYPE_ROW_DETAIL(the one region populates on expand, not lazily) andTYPE_CARD_BODY(a card is visible when its grid is);true forTYPE_TAB_BODY(preserving today's init-on-activate). An explicitlazyvalue always wins over the per-type default, for anytypeincludingnull .- Returns:
- The effective lazy flag.
-
validate
Fail-closed bean validation.Beyond the original id/populator checks, this now also enforces: a same-origin
dataUrl; a recognizedtype(when set); no nested-mapparamsvalue and noparamskey colliding with a key already present indataUrl's own query string; the card/tab-only field catalog and its two startup rejections; and no blanktitleFieldsentry.- Throws:
IllegalArgumentException- If this definition is not well-formed.
-
isSafeDetailEndpoint
Whetherendpointis a same-origin path template: no://, no//prefix, no scheme colon-before-slash, and no..path segments.- Parameters:
endpoint- The candidate template. May benull .- Returns:
true if the string is a same-origin path template.
-
toContractMap
Serializes this descriptor to the compact JSON envelope thedata-juneau-region-contractsidecar attribute carries, hand-built (rather than reflected) so the key set, order, and each nestedRegionDef.Field's wire shape are exactly the ones the contract specifies.- Returns:
- An ordered
Mapready forJson.of(...).
-