Class BulkMutateDef

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

@BeanType(properties="contractVersion,actions") public final class BulkMutateDef extends Object
The bulk-mutate opt-in for a ViewTable — the second, INDEPENDENT half of the row-selection / bulk-mutate separability guarantee.
Two required parameters make it structurally, not conventionally, safe

There is no zero-argument (or permit-less) way to obtain a BulkMutateDef: create(WritePermit, SelectionDef) takes both a WritePermit and the SelectionDef it operates against as required positional parameters. Omitting either is a compile failure, not a missed javadoc sentence — the same discipline the console's own WriteGuard uses for its WritePermit. This closes both halves of the opt-in separability guarantee by construction:

  • The WritePermit proves the caller's own write-gate was consulted before this affordance is even configured — a bulk-mutate control cannot be reached by a caller who forgot to check.
  • The SelectionDef proves a stable-row-id selection mechanism already exists for this table to target — a BulkMutateDef can never float free of the selection it acts on, so the reverse question ("which rows does this bulk action see?") is never ambiguous. This is the only direction of coupling between the two opt-ins: bulk-mutate requires selection, but selection never requires (or even references) bulk-mutate — so enabling selection alone can never surface a bulk-mutate control.
Reuses RowAction and ActionResult verbatim — N per-row writes, per-target results

A bulk action is declared as an ordinary RowAction (the RowAction wire schema is completely untouched by this type); juneau-views.js executes a bulk action as N independent, per-row invocations of the SAME single-action submit path (submitRowAction) it already uses for the per-row action menu — one fail-closed CSRF POST per selected row, each with its OWN data-juneau-inflight marker (the per-row in-flight model, driven per target) and its OWN typed ActionResult, rendered independently into that row's own outcome banner. There is deliberately no aggregate "bulk result": a partial failure among N targets can never be hidden behind an aggregate success, and each target's data-juneau-inflight marker clears on ITS OWN terminal outcome (success/failure/refusal/unknown) so a stuck marker on one target can never halt the whole table's polling.

Its own, independent contract version

Unlike SelectionDef (which is pure DOM attributes, never wire data), a bulk action LIST is itself wire data the client must parse — so it travels as its own JSON sidecar (distinct from the VIEW_META one), with its own CONTRACT_VERSION, exactly mirroring how ActionResult versions itself independently of VIEW_META rather than aliasing it. A version bump here can therefore NEVER force a VIEW_META bump (or vice versa): the two contracts are unrelated, so this opt-in cannot back the framework into the very lockstep the opt-in separability guard exists to avoid. The WritePermit carried by this builder is a server-side-only construction guard and is never serialized — only contractVersion and actions reach the wire.

Example:

SelectionDef selection = SelectionDef.create("id"); // Requires a permit the CALLER's own write-gate has already minted, and the selection it targets. BulkMutateDef bulk = BulkMutateDef.create(WritePermit.forCapability("incident:bulk-ack"), selection) .actions(RowAction.create("ack").label("Acknowledge") .endpoint("servlet:/incidents/ack").method(RowAction.Method.POST));

See Also:
Since:
10.0.0
  • Field Details

    • CONTRACT_VERSION

      public static final String CONTRACT_VERSION
      The frozen bulk-actions contract version — its own discriminator, deliberately NOT aliased to VIEW_META (see the class javadoc). Bumped only on a breaking wire change to this contract.
      See Also:
    • contractVersion

      The frozen contract-version discriminator (always "2" for this contract).
    • actions

      The declared bulk actions, in menu order. Each is an ordinary, unmodified RowAction.
  • Method Details

    • create

      public static BulkMutateDef create(WritePermit permit, SelectionDef selection)
      Starts a new BulkMutateDef, requiring proof that the caller's write-gate was consulted and the selection this bulk config will operate against.
      Parameters:
      permit - A permit the caller's OWN write-gate minted after its own checks passed. Must not be null.
      selection - The SelectionDef this bulk config operates against. Must not be null.
      Returns:
      A new BulkMutateDef with no actions yet declared.
      Throws:
      IllegalArgumentException - If permit or selection is null.
    • actions

      public BulkMutateDef actions(RowAction... value)
      Declares the bulk actions.
      Parameters:
      value - The actions, in menu order. Each declares a mutating request executed once per selected row (see the class javadoc's N-per-row-writes section). Must not be null or empty.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or empty.
    • permit

      public WritePermit permit()
      The permit proving the caller's write-gate was consulted before this config was built.
      Returns:
      The permit. Never null.
    • selection

      The selection this bulk config operates against.
      Returns:
      The selection. Never null.