Skip to content

WICKET-7177: alternative replacment method support#1385

Open
jstuyts wants to merge 1 commit intoapache:masterfrom
jstuyts:xml-replacement-in-ajax
Open

WICKET-7177: alternative replacment method support#1385
jstuyts wants to merge 1 commit intoapache:masterfrom
jstuyts:xml-replacement-in-ajax

Conversation

@jstuyts
Copy link
Contributor

@jstuyts jstuyts commented Feb 28, 2026

One implementation supporting the replacement of XML is provided.

@reiern70 reiern70 requested a review from martin-g March 13, 2026 20:31
@martin-g martin-g removed their request for review March 16, 2026 14:23
@martin-g
Copy link
Member

I am not doing web development since many years. The code looks OK but I am not the best person to review it at the moment.
I know that @kbachl is interested in removing the usage of jQuery for Wicket.NEXT.

@kbachl
Copy link
Contributor

kbachl commented Mar 16, 2026

So if I understand it correctly, the whole idea behind this patch is to allow to overcome a limitation jQuery has?
Wouldn't it be more logical to rethink the jQuery need itself?

When looking at the code the only thing I've noticed is the absence of a default legacy method to be used when no replacementMethod is available? - this might be a problem for anyone that did some manual JS to talk to wicket before, wouldn't it be?

@jstuyts
Copy link
Contributor Author

jstuyts commented Mar 16, 2026

@kbachl Yes, jQuery does not support XML, so a different way of replacing markup is needed.

I do not mind removing jQuery, but that seems like a much larger change for supporting a very narrow use case. Also, the replacement of jQuery must be 100% compatible. If developers are already sending SVG or MathML (possibly surrounded by HTML) in their responses, a replacement must not change the semantics. So even with a jQuery replacement, alternative replacement methods will still be needed.

Side note: I first tried Preact because this would also give more efficient DOM updates, but ran into 2 problems:

  • Because elements are not replaced but updated, listeners were registered multiple times.
  • I could not get XML replacement to work reliably.

This implementation was also chosen because I want to be able to mix existing (third-party) Ajax code with replacement-method aware code. Both get the same AjaxRequestTarget and can use it without interfering with each other.

The logic for replacing markup is:

  • Use the default jQuery method if no replacement method is specified. This ensures all current code behaves the same.
  • Use a registered replacement method if one is registered for the identifier.
  • Throw an error if an identifier in the response does not have a replacement method registered for it.

The changes can only be used if you are aware they are there. Existing JavaScript that calls Wicket directly will continue to work, and will see the current behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants