Class SelectionDef
ViewTable — the first of the view table's two INDEPENDENT
opt-ins.
Independent from bulk mutation, by construction
Declaring a SelectionDef adds a per-row checkbox column (and, when selectAll() is set, a
select-all header checkbox) to a view table — nothing else. It does not, by any default or
convenience, surface a bulk-mutate control: ViewTable's selection markers
(ViewTable.SELECT_ATTR and siblings) have no code
path that can render one. A view can therefore declare "selectable, for export" while categorically excluding
bulk mutation — e.g. a PagerDuty-style incident table that wants selection for a client-side export/copy
action but must never expose a multi-row mutate. A BulkMutateDef is a separate, independent type that
consumes a SelectionDef (it requires one to be constructed at all) but a SelectionDef
never requires, implies, or references one back.
Non-wire: never touches VIEW_META
A SelectionDef is deliberately not part of VIEW_META and never reaches the
JSON sidecar. ViewTable instead stamps it as
plain HTML attributes directly on the emitted <table> — ViewTable.SELECT_ATTR,
ViewTable.ROW_ID_FIELD_ATTR, ViewTable.SELECT_ALL_ATTR — mirroring the existing
ViewTable.CSRF_ATTR auto-embed pattern. The juneau-views.js runtime reads them straight off the
DOM, so a table with no SelectionDef carries none of these attributes and renders no selection UI at
all; there is no shared, independently-versioned wire contract to keep in lockstep (contrast
BulkMutateDef, whose actual bulk-action list is wire data and therefore carries its own,
separate BulkMutateDef.CONTRACT_VERSION).
Selection identity is a stable row id, never a DOM/table index
rowIdField() names the row-data key juneau-views.js reads to stamp a stable
data-juneau-row-id attribute on each rendered <tr> (see createdRow in that runtime).
Selection state is keyed by that value, never by a row's position in the DOM or in the DataTables draw —
so a poll refresh, a sort, or a page change can never retarget a selection (or a bulk mutate driven
from one) onto whichever rows now occupy those same positions. The runtime's persistence rule drops any
previously-selected id that is no longer present in the newly drawn row set, so a selection whose rows have
scrolled off screen or off the current page is never kept as a live, actionable target.
Example:
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhere aSelectionDef's row selection lives across a view's lifetime. -
Method Summary
Modifier and TypeMethodDescriptionstatic SelectionDefStarts a newSelectionDefbound to the specified stable row-id field.This selection's label field.labelField(String value) Sets the row-data field used as this row's human-readable label in a confirm dialog's target list.The row-data key used as this table's stable row identity.scope()This selection's scope.scope(SelectionDef.Scope value) Sets whether selection persists across paging/sorting/searching/refresh (SelectionDef.Scope.PERSISTENT, the default) or is dropped for any row not in the current draw (SelectionDef.Scope.PAGE).This selection's gating rules.selectableWhen(RowActionEnabledRule... value) Sets the rules that gate which rows can be selected at all.booleanWhether a select-all header checkbox is rendered.selectAll(boolean value) Sets whether a select-all header checkbox is rendered alongside the per-row checkboxes.
-
Method Details
-
create
Starts a newSelectionDefbound to the specified stable row-id field.- Parameters:
rowIdField- The row-data key whose value is this row's stable identity (e.g."id"or"incidentId"). Must not benull or blank.- Returns:
- A new
SelectionDef, withselectAll()defaulting totrue . - Throws:
IllegalArgumentException- IfrowIdFieldisnull or blank.
-
selectAll
Sets whether a select-all header checkbox is rendered alongside the per-row checkboxes.Select-all always applies only to the rows currently on screen (the current page's draw) — it can never reach into rows on another page, which would be indistinguishable from the off-screen-retarget risk this whole opt-in exists to close.
- Parameters:
value- The new value. Defaults totrue .- Returns:
- This object.
-
rowIdField
The row-data key used as this table's stable row identity.- Returns:
- The row-id field name.
-
selectAll
Whether a select-all header checkbox is rendered.- Returns:
true if select-all is enabled.
-
scope
Sets whether selection persists across paging/sorting/searching/refresh (SelectionDef.Scope.PERSISTENT, the default) or is dropped for any row not in the current draw (SelectionDef.Scope.PAGE).- Parameters:
value- The new scope. Anull value resets toSelectionDef.Scope.PERSISTENT.- Returns:
- This object.
-
selectableWhen
Sets the rules that gate which rows can be selected at all.A row failing any rule renders its checkbox disabled, carrying the failing rule's reason as both a tooltip and an accessible description; select-all skips such rows entirely.
- Parameters:
value- The gating rules. An empty ornull array clears this tonull (no gating).- Returns:
- This object.
-
labelField
Sets the row-data field used as this row's human-readable label in a confirm dialog's target list.- Parameters:
value- The field name. May benull (falls back to the row id).- Returns:
- This object.
-
scope
This selection's scope.- Returns:
- The scope. Never
null .
-
selectableWhen
This selection's gating rules.- Returns:
- The rules, or
null if none were set.
-
labelField
This selection's label field.- Returns:
- The field name, or
null if none was set.
-