Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.2.6, 1.2.7, 1.3.0-beta1
-
None
Description
(Note: I've found this on 1.2.6 – I'm reporting as existing on later versions based on reading the code.)
When any of the components replaced by an AJAX response renders multiple HTML lines, or if the AJAX response contains line breaks for any other reasons, the WicketTester.assertComponentOnAjaxResponse always returns false.
I've traced this to this statement:
boolean isComponentInAjaxResponse = ajaxResponse.matches(".*<component id=\"" + markupId
+ "\" ?>.*");
which never matches if ajaxResponse contains a \n because, in Java RegExps, the dot doesn't match these unless DOTALL is set (and it is not by default).
In the latest version I've found in SVN (sorry I'm not yet quite familiar with the codebase,) this code has been moved unchanged to org.apache.wicket.util.tester.BaseWicketTester.java – so I assume the bug is still there.
The easiest solution is to add a single-line "(?s)" flag in front of the regular expression:
boolean isComponentInAjaxResponse = ajaxResponse.matches("(?s).*<component id=\"" + markupId
+ "\" ?>.*");
Attachments
Issue Links
- is duplicated by
-
WICKET-862 isComponentOnAjaxResponse() chokes on multiline AJAX response
- Resolved