Class AjaxEventBasedInteractionsLinker<C extends org.apache.wicket.Component>
java.lang.Object
com.evolveum.midpoint.web.component.input.AjaxEventBasedInteractionsLinker<C>
- Type Parameters:
C- The type of component this linker operates on. Must extend `Component`.
- All Implemented Interfaces:
Serializable
public class AjaxEventBasedInteractionsLinker<C extends org.apache.wicket.Component>
extends Object
implements Serializable
Links a component with a `ComponentInteractionsPair` using Ajax events to enable
two-phase interaction patterns.
This linker implements the mechanism for *automatic reaction invoking* described in
`ComponentInteractionsPair`. It solves the problem of executing an action that needs
to update the UI *before* performing a long-running operation. Without this linker,
UI updates in Wicket Ajax requests are only rendered after the entire request completes,
making it impossible to show intermediate states like loading indicators.
The linker works by:
. Registering an `AjaxEventBehavior` on the component during construction via
`linkInteractions(Component, ComponentInteractionsPair)`. This behavior listens for
a custom JavaScript event named using the component's markup ID.
. When `callAction(AjaxRequestTarget)` is called, it first executes the `action` from
the interaction pair, then triggers the custom JavaScript event via
IPartialPageRequestHandler.appendJavaScript(CharSequence).
. The triggered event causes the registered `AjaxEventBehavior` to fire, which invokes
the `reaction` from the interaction pair in a *separate* Ajax request.
This separation allows the action's UI updates (such as showing a loading spinner) to be
rendered immediately, while the reaction (such as executing the long-running operation and
hiding the spinner) runs in the subsequent Ajax request.-
Method Summary
Modifier and TypeMethodDescriptionvoidcallAction(org.apache.wicket.ajax.AjaxRequestTarget target) Executes the action of the interaction pair and triggers the reaction in a subsequent Ajax request.static <C extends org.apache.wicket.Component>
AjaxEventBasedInteractionsLinker<C>linkInteractions(C component, ComponentInteractionsPair<C> interactionPair) Links a component with an interaction pair by registering an `AjaxEventBehavior` that listens for a custom JavaScript event.
-
Method Details
-
linkInteractions
public static <C extends org.apache.wicket.Component> AjaxEventBasedInteractionsLinker<C> linkInteractions(C component, ComponentInteractionsPair<C> interactionPair) Links a component with an interaction pair by registering an `AjaxEventBehavior` that listens for a custom JavaScript event. The returned linker should be retained by the caller so that `callAction(AjaxRequestTarget)` can be invoked when the interaction needs to be started.- Type Parameters:
C- The type of component, must extend `Component`.- Parameters:
component- The component to link with the interaction pair. Must not be null.interactionPair- The interaction pair defining the action and reaction behavior. Must not be null.- Returns:
- A new `AjaxEventBasedInteractionsLinker` instance configured to manage the interaction.
-
callAction
public void callAction(org.apache.wicket.ajax.AjaxRequestTarget target) Executes the action of the interaction pair and triggers the reaction in a subsequent Ajax request.- Parameters:
target- The Ajax request target for updating components.
-