Class ActionResult
A raw HTML fragment response cannot carry the distinction the consumer's non-optimistic UI rule requires: a row
must not show "acknowledged" because a request was sent, only because the remote system was read back and
said so. This typed result carries exactly that distinction — an outcome discriminator, the
authoritative row data to re-render from, a replay marker, and a refusalCode — so
the juneau-views.js runtime can paint what actually happened (success, failure, a named refusal, or
an honest unknown) rather than what the request asked for.
Its own, independent contract version
The action-result is a third independently-versioned wire contract, alongside VIEW_META
and the FTL card/slot envelope. Its
CONTRACT_VERSION is deliberately its own constant and is not aliased to
VIEW_META: aliasing a per-view contract's version onto a separate contract couples two
unrelated client/server locksteps, so this contract versions itself.
Refusals are an opaque, namespaced code — not a framework-closed enum
A refusal's refusalCode is an opaque namespaced string, not a framework-closed enum and not a
free-text message. Refusals span two independent sources, and the framework must be able to render a refusal it
has never heard of:
- Framework transport codes come from
BoundaryReason.name()(e.g.CSRF_TOKEN_MISSING), already on the wire as theX-Request-Boundaryheader and the rejection envelope'sreason. - Consumer codes are namespaced
app:/write-guard:strings for concepts Juneau knows nothing about ("not armed", "arming expired", "confirmation does not match this incident", "a previous attempt's outcome is unknown").
The runtime renders ANY code as a visible named refusal without the framework needing to know consumer concepts exist.
Reserved async terminal outcomes
cancelled and cancelled-after-effect are
reserved from day one (as VIEW_META reserved rowActions before it was implemented), even
though a synchronous write never emits them. A future async/streaming variant can therefore emit them without a
second result-contract bump and a three-sided lockstep.
Example:
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe outcome discriminator a row-action submit reports. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe frozen action-result contract version — its own discriminator, deliberately NOT aliased toVIEW_META.The frozen contract-version discriminator (always "1" for this contract).Optional human-readable supplementary message for any outcome; omitted from the wire when unset.The outcome discriminator wire token (seeActionResult.Outcome.wire()).The opaque, namespaced refusal code for arefusal; omitted from the wire for any other outcome.Whether this result is a recorded prior outcome replayed rather than re-executed; omitted from the wire when unset (the common, non-replay case).The follow-up read-only form-source URL a receipt is painted from; omitted from the wire when unset.The authoritative row payload the runtime re-renders the row from (theMERGE_ROWcase); omitted from the wire when unset. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ActionResultfailure()Starts afailureresult.Sets the optional human-readable supplementary message.static ActionResultok()Readability alias forsuccess(null)— asuccessresult that carries no row (e.g. a delete, or a navigate/redraw action).static ActionResultReadability alias forsuccess(Object).static ActionResultStarts arefusalresult carrying the named, opaque refusal code.refusalCode(String value) Sets the opaque, namespaced refusal code (seerefusalCode).Marks this result as a recorded prior outcome replayed rather than re-executed.resultForm(String value) Sets the follow-up read-only form-source URL a receipt is painted from (seeresultForm).Sets the authoritative row payload to re-render from.static ActionResultStarts asuccessresult carrying the authoritative row read back from the remote system.static ActionResultunknown()Starts anunknownresult — an honest, non-optimistic terminal state.
-
Field Details
-
CONTRACT_VERSION
The frozen action-result contract version — its own discriminator, deliberately NOT aliased toVIEW_META. Bumped only on a breaking wire change to this contract.- See Also:
-
contractVersion
The frozen contract-version discriminator (always "1" for this contract). -
outcome
The outcome discriminator wire token (seeActionResult.Outcome.wire()). -
replay
Whether this result is a recorded prior outcome replayed rather than re-executed; omitted from the wire when unset (the common, non-replay case). -
refusalCode
The opaque, namespaced refusal code for arefusal; omitted from the wire for any other outcome. Framework codes come fromEnum.name(); consumer codes are namespacedapp:/write-guard:strings (see the class javadoc). -
message
Optional human-readable supplementary message for any outcome; omitted from the wire when unset. -
row
The authoritative row payload the runtime re-renders the row from (theMERGE_ROWcase); omitted from the wire when unset. This is the row as the remote system actually reports it, not what the request asked for. -
resultForm
The follow-up read-only form-source URL a receipt is painted from; omitted from the wire when unset.Honored on
successonlyThis is the mechanical form of a receipt must never look like a receipt for a write that didn't happen. On a failure, a refusal, an unknown, or a transport failure this field is ignored, no follow-up GET is issued, and nothing is swapped — so no result host can appear for a write that did not commit.
The served payload must not carry a form
The URL serves a
ModalDef, and that payload must not declare aform. A result host is terminal by definition: the write already committed, so there is nothing left to gate. A payload carrying inputs is refused visibly rather than rendered read-only or silently stripped, because it is a consumer authoring bug and should be visible as one.It is a swap, not a new dialog
The runtime paints the receipt into the dialog that is already open, at the same layer depth, and only when that dialog opted in with
ModalDef.keepOpenOnSubmit. Set on a result whose dialog did not opt in, the swap is dropped, the success is reported unchanged, and the runtime emits one non-alarming diagnostic rather than either opening a layer or making a successful write look failed.
-
-
Constructor Details
-
ActionResult
public ActionResult()
-
-
Method Details
-
success
Starts asuccessresult carrying the authoritative row read back from the remote system.- Parameters:
row- The authoritative row payload to re-render from. Can benull (e.g. a navigate/redraw action that carries no row).- Returns:
- A new
ActionResult.
-
ok
Readability alias forsuccess(null)— asuccessresult that carries no row (e.g. a delete, or a navigate/redraw action).Example:
// Equivalent to ActionResult.success(null).message(...) return ActionResult.ok ().message("Deleted" );- Returns:
- A new
ActionResult.
-
ok
Readability alias forsuccess(Object).Example:
return ActionResult.ok (store .updatePet(pet )).message("Saved" );- Parameters:
row- The authoritative row payload to re-render from. Can benull .- Returns:
- A new
ActionResult.
-
failure
Starts afailureresult.- Returns:
- A new
ActionResult.
-
refusal
Starts arefusalresult carrying the named, opaque refusal code.- Parameters:
refusalCode- The opaque, namespaced refusal code. Must not benull or blank (a refusal with no code is exactly the free-text-message anti-pattern this contract forbids).- Returns:
- A new
ActionResult. - Throws:
IllegalArgumentException- IfrefusalCodeisnull or blank.
-
unknown
Starts anunknownresult — an honest, non-optimistic terminal state.- Returns:
- A new
ActionResult.
-
row
Sets the authoritative row payload to re-render from.- Parameters:
value- The new value. Can benull to unset.- Returns:
- This object.
-
replay
Marks this result as a recorded prior outcome replayed rather than re-executed.- Parameters:
value-true to mark this a replay;false /null to unset (omitting it from the wire).- Returns:
- This object.
-
message
Sets the optional human-readable supplementary message.- Parameters:
value- The new value. Can benull to unset.- Returns:
- This object.
-
refusalCode
Sets the opaque, namespaced refusal code (seerefusalCode).- Parameters:
value- The new value. Can benull to unset.- Returns:
- This object.
-
resultForm
Sets the follow-up read-only form-source URL a receipt is painted from (seeresultForm).- Parameters:
value- The new value. Can benull to unset.- Returns:
- This object.
-