Package io.karatelabs.markup
Interface ActionDispatchHost
- All Known Implementing Classes:
ServerMarkupContext
public interface ActionDispatchHost
Implemented by request-scoped contexts that participate in the
POST-handler dispatch chain via the
context.actions registry.
The markup template engine
checks for this capability after each ka:scope="global" block to
decide whether to dispatch a handler for the inbound POST.
Plain templating contexts (no HTTP request) don't implement this interface, so action dispatch is a silent no-op there.
-
Method Summary
Modifier and TypeMethodDescriptionThe (mutable) registry: action name → JS function.booleanWhether this request's action handler has already been dispatched.voidMark this request's action handler as dispatched.default voidsetEagerDispatchHook(Consumer<String> hook) Hook installed by the template engine; invoked by the host'scontext.actionsview every time a key is set.
-
Method Details
-
getActions
The (mutable) registry: action name → JS function. JS code populates this viacontext.actions['name'] = function(form){...}. -
isActionDispatched
boolean isActionDispatched()Whether this request's action handler has already been dispatched. The framework calls this before each potential dispatch attempt so the handler runs at most once per request. -
markActionDispatched
void markActionDispatched()Mark this request's action handler as dispatched. Called by the template engine after a successful dispatch. -
setEagerDispatchHook
Hook installed by the template engine; invoked by the host'scontext.actionsview every time a key is set. Lets the engine dispatch the matching handler eagerly — i.e. as soon as it is registered — so any state reads later in the same script block observe post-mutation data. No-op default keeps non-server (plain templating) contexts simple.
-