This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch maintenance-branch
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/maintenance-branch by this 
push:
     new 7999f7cbf9f CAUSEWAY-3976: [v2] backport, enhances client side 
javascript code, that helps with handling redirects
7999f7cbf9f is described below

commit 7999f7cbf9f861ffd8608b3a4f696a86de13950a
Author: andi-huber <[email protected]>
AuthorDate: Thu Mar 12 14:19:33 2026 +0100

    CAUSEWAY-3976: [v2] backport, enhances client side javascript code, that
    helps with handling redirects
    
    - auto correct URL origin
---
 adoc/changelog.adoc                                |  1 +
 .../causeway/viewer/wicket/ui/exec/Mediator.java   | 24 ++++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/adoc/changelog.adoc b/adoc/changelog.adoc
index c8fa01a5a56..c7efefd5f71 100644
--- a/adoc/changelog.adoc
+++ b/adoc/changelog.adoc
@@ -2,6 +2,7 @@
 
 🐞 Bug Fixes
 
+- [Wicket Viewer] Table Row Actions Redirect might fail if behind Reverse 
Proxy https://issues.apache.org/jira/browse/CAUSEWAY-3976[CAUSEWAY-3976]
 - [Commons] Internal OneShot Util may deadlock 
https://issues.apache.org/jira/browse/CAUSEWAY-3972[CAUSEWAY-3972] (potentially 
preventing App from startup)
 - Switching between Layout Variants may result in Members staying hidden 
 https://issues.apache.org/jira/browse/CAUSEWAY-3971[CAUSEWAY-3971], 
https://issues.apache.org/jira/browse/CAUSEWAY-3973[CAUSEWAY-3973]
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java
 
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java
index 94d4d24fe30..499ef3321e7 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java
@@ -193,11 +193,31 @@ private static String expanded(String urlStr) {
     }
 
     private static String javascriptFor_newWindow(final CharSequence url) {
-        return 
"function(){Wicket.Event.publish(Causeway.Topic.OPEN_IN_NEW_TAB, '" + url + 
"');}";
+        return String.format("function(){\n"
+                       + "    const url = '%s';\n"
+                       + "    const requiredOrigin = window.location.origin;\n"
+                       + "    const replacedUrl = 
url.startsWith(requiredOrigin)\n"
+                       + "      ? url\n"
+                       + "      : (() => {\n"
+                       + "          const urlObj = new URL(url);\n"
+                       + "          return requiredOrigin + urlObj.pathname + 
urlObj.search + urlObj.hash;\n"
+                       + "        })();\n"
+                       + "    
Wicket.Event.publish(Causeway.Topic.OPEN_IN_NEW_TAB, replacedUrl);\n"
+                       + "}", url);
     }
 
     private static String javascriptFor_sameWindow(final CharSequence url) {
-        return "\"window.location.href='" + url + "'\"";
+        return String.format("function(){\n"
+                       + "    const url = '%s';\n"
+                       + "    const requiredOrigin = window.location.origin;\n"
+                       + "    const replacedUrl = 
url.startsWith(requiredOrigin)\n"
+                       + "      ? url\n"
+                       + "      : (() => {\n"
+                       + "          const urlObj = new URL(url);\n"
+                       + "          return requiredOrigin + urlObj.pathname + 
urlObj.search + urlObj.hash;\n"
+                       + "        })();\n"
+                       + "    window.location.href=replacedUrl;\n"
+                       + "}", url);
     }
 
     private static void scheduleJs(final AjaxRequestTarget target, final 
String js, final int millis) {

Reply via email to