From d57ed6e622e4fe75e0a6f3c71318a847b8a6ae70 Mon Sep 17 00:00:00 2001 From: reiern70 Date: Fri, 19 Jun 2026 16:00:51 -0500 Subject: [PATCH] [https://github.com/apache/wicket/issues/1492] make partial page update creation pluggable. --- .../wicket/ajax/AjaxRequestHandler.java | 21 ++++++++++++++----- .../apache/wicket/page/PartialPageUpdate.java | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java index d9a1d386ad4..c0c650a807f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java @@ -83,10 +83,10 @@ public class AjaxRequestHandler extends AbstractPartialPageRequestHandler implem private final PartialPageUpdate update; /** a set of listeners */ - private Set listeners = null; + protected Set listeners = null; /** */ - private final Set respondListeners = new HashSet<>(); + protected final Set respondListeners = new HashSet<>(); /** see https://issues.apache.org/jira/browse/WICKET-3564 */ protected transient boolean respondersFrozen; @@ -104,7 +104,18 @@ public AjaxRequestHandler(final Page page) { super(page); - update = new XmlPartialPageUpdate(page) + update = newPartialPageUpdate(page); + } + + /** + * Factory method for {@link PartialPageUpdate}'s + * + * @param page The {@link Page} + * @return an instance of {@link PartialPageUpdate} + */ + protected PartialPageUpdate newPartialPageUpdate(final Page page) + { + return new XmlPartialPageUpdate(page) { /** * Freezes the {@link AjaxRequestHandler#listeners} before firing the event and @@ -130,7 +141,7 @@ protected void onBeforeRespond(final Response response) /** * Freezes the {@link AjaxRequestHandler#listeners}, and does not un-freeze them as the * events will have been fired by now. - * + * * @param response * the response to write to */ @@ -143,7 +154,7 @@ protected void onAfterRespond(final Response response) if (listeners != null) { final Map components = Collections - .unmodifiableMap(markupIdToComponent); + .unmodifiableMap(markupIdToComponent); for (AjaxRequestTarget.IListener listener : listeners) { diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java index 98fb9880a72..67871bdd62b 100644 --- a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java +++ b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java @@ -75,7 +75,7 @@ public abstract class PartialPageUpdate * Length of the script block that combined scripts are wrapped in. This includes the script tag, * CDATA and if CSP is enabled also the nonce. */ - private static final int SCRIPT_BLOCK_LENGTH = 100; + protected static final int SCRIPT_BLOCK_LENGTH = 100; /** * A list of scripts (JavaScript) which should be executed on the client side before the