Class RowAction
VIEW_META wire contract (the transport-agnostic
"row-action intent" model).
An FTL <@card type="datatables"> VIEW_META catalog declares zero or more of these via
rowActions; the
juneau-views.js runtime renders each as a row-menu item and, on activation, submits the declared
endpoint with the declared method as a JSON request carrying the process's CSRF token.
The frozen wire schema
This is the complete set of wire fields; it is pinned in full now so that later waves (a future declarative
modal/form + typed result) can rely on it verbatim without forcing another fail-loud
contract bump. Only id is required; every other field is optional and is omitted from the serialized
form when unset (null-valued properties are dropped).
| Field | Type / tokens | Meaning |
|---|---|---|
id | string | Stable action id (menu-item key; also the submit's logical name). |
label | string | The menu-item text. |
icon | string | Optional glyph name (resolved by the shared icon registry). |
endpoint | string | The URL the action submits to; may carry a {property}
token substituted from the current row - a value that cannot be resolved refuses the submission (see
endpoint). |
method | POST|PUT|PATCH|DELETE |
The non-safe HTTP method (see RowAction.Method). |
confirm | string | Optional confirmation prompt shown before the submit. |
form | string | Optional form-source URL supplying the action's input fields;
may carry a {property} token substituted from the current row before the confirmation GET
(see form). Blank/absent form is the confirm-only local path. |
present | page|dialog|inline |
How the action's form/confirmation is presented (see RowAction.Present); inline keeps it out of the row menu. |
onSuccess | redraw|mergeRow|navigate |
What the runtime does with a successful result (see RowAction.OnSuccess). |
enabledWhen | [{field,op,value?,reason}, ...] |
Row-state disable-with-reason rules (see enabledWhen(String,Op,Object,String)). |
visibleWhen | [{field,op,value?}, ...] |
Row-state visibility rules (see visibleWhen(VisibilityRule...)). |
tone | default|danger |
Styling of the confirmation (see RowAction.Tone); danger focuses Cancel first. |
confirmLabel | string | Text of the confirm button; defaults to the action's label. |
confirmRenderer | string | Name of a confirm renderer registered with the client runtime; absent means the built-in modal.
Like confirm, it is not consulted when an inline cell edit commits (that never prompts). |
enabledWhen was added after this schema was first frozen; like ModalDef#barSlot, it is
additive-only (VIEW_META — a RowAction that leaves it unset serializes
unchanged, and old juneau-views.js ignores the unknown key.
Why method cannot be a safe method
RowAction.Method enumerates only POST/PUT/PATCH/DELETE, so a safe (CSRF-exempt)
method cannot be declared at all — a build-time refusal by construction. This mirrors the server boundary:
MethodSafety fails any @Mutating operation bound to a safe method at
startup, and LoopbackBoundary applies its Origin/CSRF/JSON checks
only to non-safe methods. A mutating action bound to GET would be a CSRF-able write; the type system
forbids expressing one.
Per-row {property} substitution in endpoint and form
endpoint and form may each carry a {property} token
(e.g. {id}, as in the example below) that the client-side runtime substitutes from the row — the
SAME mechanism, same token grammar, and same per-value escaping as the linked cell renderer's
href interpolation. Unlike a rendered href, these URLs are fetched (form: confirmation GET) or
submitted (endpoint: mutating write), so an unresolved substitution refuses instead of issuing a
malformed request; see each setter's javadoc for the full contract. A value with no token is unaffected and
is used as declared. A blank/absent form is the confirm-only local path (no
GET), not a refusal.
Example:
RowAction
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow an action behaves when driven from a bulk-mutate toolbar.static enumThe non-safe HTTP method a row action submits with.static enumWhat the runtime does with a successful action result.static enumHow a row action's form/confirmation is presented.static enumThe visual tone of a row action's confirmation. -
Field Summary
FieldsModifier and TypeFieldDescriptionOptional confirmation prompt shown before the submit, or literalfalse for none (seenoConfirm()).Optional text of the confirm button;null means the action'slabel.Optional name of a confirm renderer registered with the client runtime;null means the built-in modal.Optional confirm-dialog title when this action is driven in bulk.The row-state rules that must all match for this action to render enabled.The URL this action submits to (seeendpointfor the{property}substitution grammar).Optional form-source URL supplying the action's input fields.Optional glyph/icon name (resolved by the shared icon registry).The stable action id (menu-item key; also the submit's logical name).The menu-item text.The non-safe HTTP method wire token (seeRowAction.Method.wire()).Optional success-behavior hint wire token (seeRowAction.OnSuccess.wire()).Optional presentation hint wire token (seeRowAction.Present.wire()).Optional confirmation tone wire token (seeRowAction.Tone.wire()).The rules that must all match for this action to render at all. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbulkMode(RowAction.BulkMode value) Sets how this action behaves when driven from a bulk-mutate toolbar: one call per selected row (RowAction.BulkMode.PER_ROW, the default) or a single call carrying every selected id (RowAction.BulkMode.AGGREGATE).Sets the confirmation prompt shown before the submit.confirmLabel(String value) Sets the text of the confirm button.confirmRenderer(String value) Sets the name of the confirm renderer to use for this action's confirmation.confirmTitle(String value) Sets the confirm dialog's title when this action is driven in bulk (e.g.static RowActionStarts a newRowActionwith the specified stable action id.enabledWhen(String field, Op op, Object value, String reason) Gates this action on the row's own state, comparing one field against one value.enabledWhen(String field, Op op, String reason) Gates this action on the presence or absence of a row field.Sets the URL this action submits to.Sets the form-source URL supplying the action's input fields.Sets the glyph/icon name.Sets the menu-item text.method(RowAction.Method value) Sets the non-safe HTTP method this action submits with.Marks this action as never requiring a confirm dialog, in bulk or otherwise — writes a literalfalse onto the sameconfirmwire key a confirm message would otherwise occupy.onSuccess(RowAction.OnSuccess value) Sets the success-behavior hint.present(RowAction.Present value) Sets the presentation hint.tone(RowAction.Tone value) Sets the confirmation tone.visibleWhen(VisibilityRule... rules) Hides this action, per row, unless every rule matches (seevisibleWhenfor the semantics).
-
Field Details
-
id
The stable action id (menu-item key; also the submit's logical name). -
label
The menu-item text. -
icon
Optional glyph/icon name (resolved by the shared icon registry). -
endpoint
The URL this action submits to (seeendpointfor the{property}substitution grammar). -
method
The non-safe HTTP method wire token (seeRowAction.Method.wire()). -
confirm
Optional confirmation prompt shown before the submit, or literalfalse for none (seenoConfirm()). -
confirmTitle
Optional confirm-dialog title when this action is driven in bulk. -
bulkMode
-
form
Optional form-source URL supplying the action's input fields. -
present
Optional presentation hint wire token (seeRowAction.Present.wire()). -
onSuccess
Optional success-behavior hint wire token (seeRowAction.OnSuccess.wire()). -
enabledWhen
The row-state rules that must all match for this action to render enabled.null or empty means "never gated" — the action renders exactly as it does today. SeeenabledWhen(String,Op,Object,String)for the semantics, which mirrorActionRef.enabledWhenon the detail-panelActionBar(widgets module): presentation only, disabled never hidden, first-declared-rule-wins, and a field the row does not carry fails closed. -
visibleWhen
The rules that must all match for this action to render at all.null or empty means always visible.Unlike
enabledWhen, which disables but never hides, a row whose data does not satisfy every rule here has this action hidden entirely (re-evaluated on every draw). PreferenabledWhen, which tells the user why an action is unavailable, and hide only when the action is irrelevant to the row. Still presentation only — the endpoint must authorize independently. The evaluation map is the row, plus the page'sfactsunder afacts.prefix, so a rule can test either"status"or"facts.viewer.roles". -
tone
Optional confirmation tone wire token (seeRowAction.Tone.wire()). -
confirmLabel
Optional text of the confirm button;null means the action'slabel. -
confirmRenderer
Optional name of a confirm renderer registered with the client runtime;null means the built-in modal.
-
-
Constructor Details
-
RowAction
public RowAction()
-
-
Method Details
-
create
Starts a newRowActionwith the specified stable action id.- Parameters:
id- The stable action id. Must not benull or blank.- Returns:
- A new mutable
RowActionto chain builder calls on. - Throws:
IllegalArgumentException- Ifidisnull or blank.
-
label
Sets the menu-item text.- Parameters:
value- The new value.- Returns:
- This object.
-
icon
Sets the glyph/icon name.- Parameters:
value- The new value.- Returns:
- This object.
-
endpoint
Sets the URL this action submits to.May contain one or more
{property}tokens (e.g."servlet:/incidents/{id}/ack"), substituted from the CURRENT ROW's own already-fetched data at submit time — the client-side (juneau-views.js) runtime, not this Java layer, performs the substitution, by delegating to the identicalinterpolateHrefhelper thelinkedcell renderer uses (juneau-renders.js): the SAME token grammar (any{property}, not a hardcoded{id}) and the SAME per-valueencodeURIComponentescaping — unchanged.Divergence from a rendered
hrefis deliberate: because this URL is submitted rather than merely rendered, the runtime refuses the submission (renders a visible refusal; issues no request; never a request-time exception) instead of firing a malformed or undeclared write, when:- a
{property}token's row value is absent,null , or blank; - the resolved URL still carries an unsubstituted
{property}token (e.g. the page shippedjuneau-views.jswithout itsjuneau-renders.jspeer); - the resolved URL contains a
..path segment (which browser URL resolution would otherwise normalize into a different, undeclared endpoint); or - no
endpointis declared at all.
Column.hrefkeeps substituting to an empty string in each of these cases, because a rendered link is not a write.Backward compatible, narrowed: an
endpointwith no{...}token is still issued as declared (three of the four guards above cannot fire on it; the fourth, the..check, only fires on an author-declared..). AnendpointWITH a token now refuses in cases that previously submitted a malformed URL (e.g."servlet:/incidents//ack"for a row with noid) rather than issuing it.- Parameters:
value- The new value.- Returns:
- This object.
- a
-
method
Sets the non-safe HTTP method this action submits with.Only a
RowAction.Method(POST/PUT/PATCH/DELETE) can be passed, so a safe method can never be declared — the build-time half of the safe-method refusal.- Parameters:
value- The method. Must not benull .- Returns:
- This object.
-
confirm
Sets the confirmation prompt shown before the submit.The prompt is shown whatever
presentsays: withoutRowAction.Present.DIALOGthe action opens a confirm-only dialog (or itsconfirmRenderer) and submits only on Confirm. UsenoConfirm()for an action that never prompts.One surface never prompts: committing an inline cell edit (the
editrenderer's pencil) submits the action directly on Enter or blur even when the action declares a confirm or aconfirmRenderer, because a dialog opening on Enter or blur is awkward. Do not wire a confirm-guarded action to an inline editor.- Parameters:
value- The new value.- Returns:
- This object.
-
bulkMode
Sets how this action behaves when driven from a bulk-mutate toolbar: one call per selected row (RowAction.BulkMode.PER_ROW, the default) or a single call carrying every selected id (RowAction.BulkMode.AGGREGATE).- Parameters:
value- The new mode. Anull value clears it (the default,RowAction.BulkMode.PER_ROW).- Returns:
- This object.
-
confirmTitle
Sets the confirm dialog's title when this action is driven in bulk (e.g."Abort {count} pending changes").- Parameters:
value- The title template. May benull .- Returns:
- This object.
-
noConfirm
Marks this action as never requiring a confirm dialog, in bulk or otherwise — writes a literalfalse onto the sameconfirmwire key a confirm message would otherwise occupy.- Returns:
- This object.
-
form
Sets the form-source URL supplying the action's input fields.May contain one or more
{property}tokens (e.g."/data/alerts/{id}/ack-form"), substituted from the CURRENT ROW's own already-fetched data before the confirmation GET — the client-side (juneau-views.js) runtime, not this Java layer, performs the substitution, by delegating to the identicalinterpolateHrefhelper thelinkedcell renderer uses (juneau-renders.js): the SAME token grammar (any{property}, not a hardcoded{id}) and the SAME per-valueencodeURIComponentescaping.Divergence from a rendered
href: because this URL is fetched (the confirmation GET) rather than merely rendered, the runtime refuses the open (renders a visible refusal; issues nofetch) instead of GETting a malformed or undeclared path, when:- a
{property}token's row value is absent,null , or blank; - the resolved URL still carries an unsubstituted
{property}token (e.g. the page shippedjuneau-views.jswithout itsjuneau-renders.jspeer); or - the resolved URL contains a
..path segment (which browser URL resolution would otherwise normalize into a different, undeclared endpoint).
hrefkeeps substituting to an empty string in each of these cases, because a rendered link is not a fetch.Divergence from
endpoint: a blank/absentformis still the confirm-only local path (no GET), not ano-endpointrefusal. A token-lessformis fetched as declared.- Parameters:
value- The new value. Can benull or blank for a confirm-only dialog.- Returns:
- This object.
- a
-
present
Sets the presentation hint.- Parameters:
value- The presentation. Must not benull .- Returns:
- This object.
-
onSuccess
Sets the success-behavior hint.- Parameters:
value- The success behavior. Must not benull .- Returns:
- This object.
-
enabledWhen
Gates this action on the row's own state, comparing one field against one value.Mirrors
ActionRef.enabledWhen(String,Op,Object,String)on the detail-panelActionBar(widgets module). This is presentation only, never the authorization gate: the endpoint behind this action must still perform its own real check and refuse on its own authority. A row whose field does not satisfy every declared rule renders this action present but disabled, carryingreasonas its explanation; disabled, never hidden. Call this more than once to declare more than one rule — all of them must match, and when several fail, the runtime shows the first-declared failing reason. -
enabledWhen
Gates this action on the presence or absence of a row field.The presence-based counterpart of
enabledWhen(String,Op,Object,String), which carries the full semantics.- Parameters:
field- The row field to test. Must not benull or blank.op- The comparison operator. Must beOp.PRESENTorOp.ABSENT.reason- Why the action is unavailable when this rule does not match. Must not benull or blank.- Returns:
- This object.
-
visibleWhen
Hides this action, per row, unless every rule matches (seevisibleWhenfor the semantics).- Parameters:
rules- The rules; all must match. Replaces any rules set by an earlier call.- Returns:
- This object.
-
tone
Sets the confirmation tone.- Parameters:
value- The tone. Must not benull .- Returns:
- This object.
-
confirmLabel
Sets the text of the confirm button.- Parameters:
value- The label. Can benull to fall back tolabel.- Returns:
- This object.
-
confirmRenderer
Sets the name of the confirm renderer to use for this action's confirmation.The name must be registered on the client with
JuneauViews.rowActions.registerConfirmRenderer; an unregistered name refuses the confirmation.A renderer on its own, with no
confirmtext, is enough to prompt: the action asks the renderer before it submits even withoutpresent(DIALOG), and the prompt is titled with the action's name.- Parameters:
value- The renderer name. Can benull for the built-in modal.- Returns:
- This object.
-