Interface ComponentInteractionsPair<C extends org.apache.wicket.Component>
- Type Parameters:
C- The type of component this interaction pair works with
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ActivityIndicationInteractionsPair
public interface ComponentInteractionsPair<C extends org.apache.wicket.Component>
extends Serializable
Represents a pair of interactions which allows to run an "action" on an arbitrary Ajax request, while triggering
a reaction in the "automatic" Ajax request of different component.
Both action and reaction of the interaction pair can operate on a component (which should be the same for both),
which may be unrelated to the Ajax request which triggers the action.
To illustrate this, imagine a button and a separate label.When you click on the button, you want to trigger some
long-running action and modify the label icon or text to indicate that the action is running. You can't do that
easily, because the label would not be updated before the action is done, that is of course too late.
You can however "switch" the order. On button click, you will only update the icon/text of the label - the
`action` of the interactions pair. Then in the `reaction` of the interactions pair, you will trigger the action, and
after it is finished, you will reset the label icon/text. In both cases, the component passed to both `action` and
`reaction` methods is the label. But the `action` method is run as part of the button Ajax.
Above would of course not work on its own. This interface is supposed to be used in combination with a "linker",
which implements the mechanism of the automatic `reaction` invoking.
-
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes the action on the specified component.default ComponentInteractionsPair<C>actionAndThen(SerializableBiConsumer<C, org.apache.wicket.ajax.AjaxRequestTarget> nextOnBefore) Creates a new interaction pair with an additional action to be executed after this pair's action, while keeping the original reaction.default ComponentInteractionsPair<C>andThen(ComponentInteractionsPair<C> other) Combines this interaction pair with another one, executing both actions and both reactions in sequence.voidExecutes the reaction on the specified component.default ComponentInteractionsPair<C>reactionAndThen(SerializableBiConsumer<C, org.apache.wicket.ajax.AjaxRequestTarget> nextOnAfter) Creates a new interaction pair with an additional reaction to be executed after this pair's reaction, while keeping the original action.
-
Method Details
-
action
Executes the action on the specified component. This method is called to perform the primary operation associated with this interaction pair. The action typically modifies the component state or performs some business logic in response to a user interaction.- Parameters:
component- The Wicket component on which the action is performedrequest- The Ajax request target used for updating the component or adding other components to the Ajax response
-
reaction
Executes the reaction on the specified component. This method is called to perform a follow-up operation after the main action. The reaction typically handles cleanup, state restoration, or secondary updates that should occur after the primary action has been executed.- Parameters:
component- The Wicket component on which the reaction is performedrequest- The Ajax request target used for updating the component or adding other components to the Ajax response
-
andThen
Combines this interaction pair with another one, executing both actions and both reactions in sequence. The returned interaction pair will execute this pair's action followed by the other pair's action, and similarly for reactions. This allows for composing multiple interaction behaviors into a single unified pair.- Parameters:
other- The other interaction pair to chain after this one- Returns:
- A new interaction pair that executes both pairs in sequence
-
actionAndThen
default ComponentInteractionsPair<C> actionAndThen(SerializableBiConsumer<C, org.apache.wicket.ajax.AjaxRequestTarget> nextOnBefore) Creates a new interaction pair with an additional action to be executed after this pair's action, while keeping the original reaction. This method is useful when you want to extend the action behavior without modifying the reaction. The provided consumer will be called after this pair's action completes.- Parameters:
nextOnBefore- The additional action to execute after this pair's action- Returns:
- A new interaction pair with the combined action and original reaction
-
reactionAndThen
default ComponentInteractionsPair<C> reactionAndThen(SerializableBiConsumer<C, org.apache.wicket.ajax.AjaxRequestTarget> nextOnAfter) Creates a new interaction pair with an additional reaction to be executed after this pair's reaction, while keeping the original action. This method is useful when you want to extend the reaction behavior without modifying the action. The provided consumer will be called after this pair's reaction completes.- Parameters:
nextOnAfter- The additional reaction to execute after this pair's reaction- Returns:
- A new interaction pair with the original action and combined reaction
-