This is an automated email from the ASF dual-hosted git repository.
reiern70 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new 2afa365c2b [https://github.com/apache/wicket/issues/1492] make partial
page update creation pluggable.
2afa365c2b is described below
commit 2afa365c2bfc8147d8050c858367970fdb2f7b48
Author: reiern70 <[email protected]>
AuthorDate: Fri Jun 19 16:00:51 2026 -0500
[https://github.com/apache/wicket/issues/1492] make partial page update
creation pluggable.
---
.../org/apache/wicket/ajax/AjaxRequestHandler.java | 40 ++++++++++++++--------
.../org/apache/wicket/page/PartialPageUpdate.java | 2 +-
2 files changed, 27 insertions(+), 15 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 d9a1d386ad..fb0ba56c25 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
@@ -80,13 +80,13 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
/**
* Collector of page updates.
*/
- private final PartialPageUpdate update;
+ private PartialPageUpdate update;
/** a set of listeners */
- private Set<AjaxRequestTarget.IListener> listeners = null;
+ protected Set<AjaxRequestTarget.IListener> listeners = null;
/** */
- private final Set<ITargetRespondListener> respondListeners = new
HashSet<>();
+ protected final Set<ITargetRespondListener> respondListeners = new
HashSet<>();
/** see https://issues.apache.org/jira/browse/WICKET-3564 */
protected transient boolean respondersFrozen;
@@ -103,8 +103,17 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
public AjaxRequestHandler(final Page page)
{
super(page);
+ }
- update = new XmlPartialPageUpdate(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 +139,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
/**
* 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 +152,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
if (listeners != null)
{
final Map<String, Component> components
= Collections
-
.unmodifiableMap(markupIdToComponent);
+
.unmodifiableMap(markupIdToComponent);
for (AjaxRequestTarget.IListener
listener : listeners)
{
@@ -174,13 +183,16 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
@Override
public PartialPageUpdate getUpdate()
{
+ if (update == null) {
+ update = newPartialPageUpdate(getPage());
+ }
return update;
}
@Override
public final Collection<? extends Component> getComponents()
{
- return update.getComponents();
+ return getUpdate().getComponents();
}
/**
@@ -194,7 +206,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
logData = new PageLogData(getPage());
}
- update.detach(requestCycle);
+ getUpdate().detach(requestCycle);
}
/**
@@ -206,7 +218,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
if (obj instanceof AjaxRequestHandler)
{
AjaxRequestHandler that = (AjaxRequestHandler)obj;
- return update.equals(that.update);
+ return getUpdate().equals(that.update);
}
return false;
}
@@ -218,7 +230,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
public int hashCode()
{
int result = "AjaxRequestHandler".hashCode();
- result += update.hashCode() * 17;
+ result += getUpdate().hashCode() * 17;
return result;
}
@@ -265,7 +277,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
final String encoding =
app.getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
- update.setContentType(response, encoding);
+ getUpdate().setContentType(response, encoding);
// Make sure it is not cached by a client
response.disableCaching();
@@ -276,7 +288,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
// WICKET-7074 we need to write to a temporary buffer,
otherwise, if an exception is produced,
// and a redirect is done we will end up with a malformed XML
final StringResponse bodyResponse = new StringResponse();
- update.writeTo(bodyResponse, encoding);
+ getUpdate().writeTo(bodyResponse, encoding);
if (filters == null || filters.isEmpty())
{
response.write(bodyResponse.getBuffer());
@@ -290,7 +302,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
private boolean shouldRedirectToPage(IRequestCycle requestCycle)
{
- if (update.containsPage())
+ if (getUpdate().containsPage())
{
return true;
}
@@ -333,7 +345,7 @@ public class AjaxRequestHandler extends
AbstractPartialPageRequestHandler implem
@Override
public String toString()
{
- return "[AjaxRequestHandler@" + hashCode() + " responseObject
[" + update + "]";
+ return "[AjaxRequestHandler@" + hashCode() + " responseObject
[" + getUpdate() + "]";
}
/**
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 98fb9880a7..67871bdd62 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