deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-1043 Loop redirect in error-page (404) with CLIENTWINDOW
Date Fri, 18 Dec 2015 15:16:15 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 9ba6c92bd -> 086871c02


DELTASPIKE-1043 Loop redirect in error-page (404) with CLIENTWINDOW

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/086871c0
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/086871c0
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/086871c0

Branch: refs/heads/master
Commit: 086871c024dd1a7e1c97d5d1caa1c1f593372b46
Parents: 9ba6c92
Author: tandraschko <tandraschko@apache.org>
Authored: Fri Dec 18 16:15:41 2015 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Fri Dec 18 16:15:41 2015 +0100

----------------------------------------------------------------------
 .../strategy/ClientSideWindowStrategy.java      | 10 +++++--
 .../jsf/impl/util/ClientWindowHelper.java       | 30 ++++++++++++--------
 .../deltaspike/jsf/impl/util/JsfUtils.java      |  6 ++++
 .../main/resources/static/windowhandler.html    |  2 +-
 4 files changed, 33 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/086871c0/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
index 5957c73..572da07 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
@@ -42,6 +42,7 @@ public class ClientSideWindowStrategy extends AbstractClientWindowStrategy
 
     private static final String UNINITIALIZED_WINDOW_ID_VALUE = "uninitializedWindowId";
     private static final String WINDOW_ID_REPLACE_PATTERN = "$$windowIdValue$$";
+    private static final String REQUEST_URL_REPLACE_PATTERN = "$$requestUrl$$";
     private static final String NOSCRIPT_URL_REPLACE_PATTERN = "$$noscriptUrl$$";
 
     /**
@@ -116,8 +117,13 @@ public class ClientSideWindowStrategy extends AbstractClientWindowStrategy
             }
 
             // set the windowId value in the javascript code
-            windowHandlerHtml = windowHandlerHtml.replace(WINDOW_ID_REPLACE_PATTERN, windowId);
-
+            windowHandlerHtml = windowHandlerHtml.replace(WINDOW_ID_REPLACE_PATTERN,
+                    windowId);
+            // set the current request url
+            // on the client we can't use window.location as the location
+            // could be a different when using forwards
+            windowHandlerHtml = windowHandlerHtml.replace(REQUEST_URL_REPLACE_PATTERN,
+                    ClientWindowHelper.constructRequestUrl(externalContext));
             // set the noscript-URL for users with no JavaScript
             windowHandlerHtml =
                     windowHandlerHtml.replace(NOSCRIPT_URL_REPLACE_PATTERN, getNoscriptUrl(externalContext));

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/086871c0/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
index 59b15d9..858c1f3 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
@@ -53,7 +53,24 @@ public abstract class ClientWindowHelper
         public static final String REQUEST_WINDOW_ID_PREFIX = "dsrwid-";
     }
 
+    public static String constructRequestUrl(ExternalContext externalContext)
+    {
+        String url = externalContext.getRequestContextPath()
+                + externalContext.getRequestServletPath();
 
+        if (externalContext.getRequestPathInfo() != null)
+        {
+            url += externalContext.getRequestPathInfo();
+        }
+        
+        url = JsfUtils.addRequestParameters(externalContext, url, true);
+        //TODO check if it isn't better to fix addRequestParameters itself
+        //only #encodeResourceURL is portable currently
+        url = externalContext.encodeResourceURL(url);
+        
+        return url;
+    }
+    
     /**
      * Handles the initial redirect for the LAZY mode, if no windowId is available in the
current request URL.
      *
@@ -68,18 +85,7 @@ public abstract class ClientWindowHelper
 
         ExternalContext externalContext = facesContext.getExternalContext();
 
-        String url = externalContext.getRequestContextPath()
-                + externalContext.getRequestServletPath();
-
-        if (externalContext.getRequestPathInfo() != null)
-        {
-            url += externalContext.getRequestPathInfo();
-        }
-
-        url = JsfUtils.addRequestParameters(externalContext, url, true);
-        //TODO check if it isn't better to fix addRequestParameters itself
-        //only #encodeResourceURL is portable currently
-        url = facesContext.getExternalContext().encodeResourceURL(url);
+        String url = constructRequestUrl(externalContext);
 
         // remember the initial redirect windowId till the next request - see #729
         addRequestWindowIdCookie(facesContext, newWindowId, newWindowId);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/086871c0/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
index e0b55cd..6914182 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
@@ -44,6 +44,7 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.deltaspike.core.util.StringUtils;
 
 public abstract class JsfUtils
 {
@@ -187,6 +188,11 @@ public abstract class JsfUtils
                 if (!url.contains(entry.getKey() + "=" + value) &&
                         !url.contains(entry.getKey() + "=" + encodeURLParameterValue(value,
externalContext)))
                 {
+                    if (StringUtils.isEmpty(entry.getKey()) && StringUtils.isEmpty(value))
+                    {
+                        continue;
+                    }
+
                     if (!existingParameters)
                     {
                         finalUrl.append("?");

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/086871c0/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html b/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
index c4a956b..bfd46d9 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
+++ b/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
@@ -142,7 +142,7 @@
 
                 var requestToken = dswh.utils.generateRequestToken();
 
-                var redirectUrl = window.location.href;
+                var redirectUrl = '$$requestUrl$$';
                 redirectUrl = dswh.utils.setUrlParam(redirectUrl, "dsrid", requestToken);
                 // we still add the windowId page param to support lazy windowId dropping
for some clients
                 redirectUrl = dswh.utils.setUrlParam(redirectUrl, "dswid", urlId);


Mime
View raw message