Class ActionRef
- All Implemented Interfaces:
ActionBarItem
This type deliberately does not import any views-module type. Existence of the named action on the
enclosing view's action catalog is checked in views (RegionDef / serving-path validation), never
here. The bar does not grow its own write protocol (no endpoint / method / csrf fields).
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionThe visual weight this bar paints for this action.The row-state rules that must all match for this action to be offered, in the author's declared order.The opaque action id. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionemphasis(ActionRef.Emphasis value) Sets the visual weight this bar paints for this action.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.static ActionRefCreates an action reference with the specified id.
-
Field Details
-
id
The opaque action id. Must not be blank. -
emphasis
The visual weight this bar paints for this action. Defaults toActionRef.Emphasis.SECONDARY. -
enabledWhen
The row-state rules that must all match for this action to be offered, in the author's declared order.nullor empty means the action is never gated on row state. SeeenabledWhen(String,Op,Object,String)for the semantics, including the deliberate absence of a hide/show mode.
-
-
Constructor Details
-
ActionRef
public ActionRef()
-
-
Method Details
-
of
Creates an action reference with the specified id.- Parameters:
id- The action id. Must not benull or blank.- Returns:
- A new
ActionRef.
-
emphasis
Sets the visual weight this bar paints for this action.This is a per-bar rendering property, not a property of the action itself — the same action can be the primary button in one bar (e.g. the Detail View header) and an ordinary item in another. Java-only: never marshalled into
VIEW_META, so it does not move a bar-contract version.- Parameters:
value- The emphasis. Must not benull .- Returns:
- This object.
-
enabledWhen
Gates this action on the row's own state, comparing one field against one value.A row whose field does not satisfy every declared rule is offered the action present but disabled, carrying
reasonas its explanation. Call this more than once to declare more than one rule; all of them must match.This is presentation only — never the authorization gate:
The rule exists so an operator is not offered a button that cannot possibly work. The server still re-reads the row's state and refuses on its own authority; a client-side rule that quietly became the only check would be a regression, not an optimization. Nothing here is a substitute for the server's own refusal.
Disabled, never hidden:
Prefer disabled; hide only when the action is irrelevant. A detail-panel action has no
visibleWhen(...): removing a momentarily-impossible action makes the bar's contents jump between rows and hides the fact that the action exists at all. When an action is invalid for an entire view rather than per row, omit it from that view's action list — that is the right tool, and it is why per-row hiding is not offered.Which reason an operator sees:
When several rules on one action fail, the first-declared one wins and evaluation stops there. The author's ordering is therefore the priority mechanism: no severity field, no concatenation, no most-specific-rule heuristic. The runtime surfaces that one reason through both a native tooltip and
aria-describedby, and clears both again when the rules pass.A field the row does not carry fails closed:
A rule keyed on a field the enclosing panel never declares is rejected at startup. If the field is nonetheless missing from a row's payload at runtime, the rule fails and the action disables — including for
Op.ABSENT, which tests a field that is present and empty rather than one that was never returned.Java-only, like
emphasis: the bar is painted into server-emitted markup and is never marshalled into the view's JSON sidecar, so this does not move a bar-contract version.- Parameters:
field- The row field to test. Must not benull or blank.op- The comparison operator. Must beOp.EQorOp.NE.value- The comparison value. Must not benull .reason- Why the action is unavailable when this rule does not match. Must not benull or blank — with the action disabled rather than removed, this string is the only thing that explains an inert button.- Returns:
- This object.
-
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 — presentation only, disabled rather than hidden, first-declared reason wins, and a field the row does not carry fails closed.- 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.
-