Skip to content

Commit

Permalink
ZK-5634: Page will fail to load with a searchbox when source map is e…
Browse files Browse the repository at this point in the history
…nabled
  • Loading branch information
DevChu committed Feb 16, 2024
1 parent 7c9c535 commit 577d86f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions zk/src/main/java/org/zkoss/zk/ui/http/WpdExtendlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,20 @@ protected byte[] retrieve(HttpServletRequest request, HttpServletResponse respon
dividedElements = _dividedWpds.get(lastPart);
if (dividedElements == null) { // dynamic
try {
return processDynamicWpdWithSourceMapIfAny(request, response, pkgName, path);
byte[] dynamicContent = processDynamicWpdWithSourceMapIfAny(request, response, pkgName, path);
if (dynamicContent != null) {
return dynamicContent;
} else {
dividedElements = _dividedWpds.get(lastPart);
}
} catch (Exception e) {
log.error("fail to process source for source map", e);
return new byte[]{};
}
}
request.setAttribute(SOURCE_MAP_DIVIDED_WPDS, dividedElements);
Integer packagePartsCnt = _dividedPackageCnt.get(pkgName);
if (packagePartsCnt != null && packagePartsCnt > 1) {
if (packagePartsCnt != null && packagePartsCnt >= 1) {
int num = Integer.parseInt(lastPart.replace(pkgName, "").replace(".wpd", ""));
request.setAttribute(SOURCE_MAP_DIVIDED_WPDS_NUMBER, num);
}
Expand Down Expand Up @@ -1043,6 +1048,11 @@ private byte[] processDynamicWpdWithSourceMapIfAny(HttpServletRequest request, H
StringBuilder sb = new StringBuilder();
int index = 0;
String lastWpd = null;
if (dividedPaths.size() == 0) {
throw new UiException("Failed to load the resource: " + path);
} else if (dividedPaths.size() == 1) {
return null; // only one. just add it.
}
for (String dividedPath : dividedPaths) {
String scriptVariableName = "script" + index++;
sb.append("var ").append(scriptVariableName).append("=document.createElement('script');");
Expand Down
1 change: 1 addition & 0 deletions zktest/src/main/webapp/test2/F100-ZK-5590.zul
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Copyright (C) 2023 Potix Corporation. All Rights Reserved.
<label id="lb"/>
<button label="click" onClick='lb.value="Clicked"'/>
<rangeslider id="rs1" onRangeValueChange='Clients.log(rs1.getStartValue() + "," + rs1.getEndValue())'/>
<searchbox></searchbox>
</zk>

0 comments on commit 577d86f

Please sign in to comment.