Class ActionRef

java.lang.Object
org.apache.juneau.console.widgets.ActionRef
All Implemented Interfaces:
ActionBarItem

public class ActionRef extends Object implements ActionBarItem
An opaque id naming a write action on the enclosing view.

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
  • Field Details

  • Constructor Details

  • Method Details

    • of

      public static ActionRef of(String id)
      Creates an action reference with the specified id.
      Parameters:
      id - The action id. Must not be null 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 be null.
      Returns:
      This object.
    • enabledWhen

      public ActionRef enabledWhen(String field, Op op, Object value, String reason)
      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 reason as 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 be null or blank.
      op - The comparison operator. Must be Op.EQ or Op.NE.
      value - The comparison value. Must not be null.
      reason - Why the action is unavailable when this rule does not match. Must not be null or blank — with the action disabled rather than removed, this string is the only thing that explains an inert button.
      Returns:
      This object.
    • enabledWhen

      public ActionRef enabledWhen(String field, Op op, String reason)
      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 be null or blank.
      op - The comparison operator. Must be Op.PRESENT or Op.ABSENT.
      reason - Why the action is unavailable when this rule does not match. Must not be null or blank.
      Returns:
      This object.