Class RowActionEnabledRule

java.lang.Object
org.apache.juneau.console.views.RowActionEnabledRule

@BeanType(properties="field,op,value,reason") public class RowActionEnabledRule extends Object
A declarative disable-with-reason rule gating a RowAction on the row's own state, in the VIEW_META wire contract.

Mirrors org.apache.juneau.console.widgets.ActionRef.EnabledRule on a detail-panel action bar, but rides the wire as a plain data rule the same way a row-class rule does — a table row is polled/client-rendered rather than server-painted, so this type follows that wire shape, not ActionRef.EnabledRule's Java-only one. Serializes to {"field":..., "op":..., "value"?:..., "reason":...}, with op carrying Op.wire()'s lowercase token (a String), not the Java enum.

The eq/ne operators require a value; the present/absent operators test only whether row[field] is non-null/non-empty and therefore omit value from the wire.

Presentation only, never the authorization gate:

A row whose field does not satisfy this rule renders its RowAction present but disabled, carrying reason as a tooltip and aria-describedby text. The endpoint behind the action must still perform its own real check and refuse on its own authority; this rule is never a substitute for that check.

See Also:
Since:
10.0.0
  • Field Details

    • field

      public String field
      The row field this rule tests.
    • op

      public String op
      The wire token of the comparison operator (see Op.wire()).
    • value

      public Object value
      The comparison value for eq/ne; omitted for present/absent.
    • reason

      public String reason
      Why the action is unavailable when this rule does not match. Required — must not be blank.
  • Constructor Details

  • Method Details

    • of

      public static RowActionEnabledRule of(String field, Op op, Object value, String reason)
      Creates a value-based rule for the eq/ne operators.
      Parameters:
      field - The row field to test. Must not be null or blank.
      op - The 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.
      Returns:
      A new RowActionEnabledRule.
      Throws:
      IllegalArgumentException - If field/reason is null or blank, op is not value-based, or value is null.
    • of

      public static RowActionEnabledRule of(String field, Op op, String reason)
      Creates a presence-based rule for the present/absent operators.
      Parameters:
      field - The row field to test. Must not be null or blank.
      op - The 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:
      A new RowActionEnabledRule with no value.
      Throws:
      IllegalArgumentException - If field/reason is null or blank, or op is value-based.