You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/01/21 15:35:07 UTC

svn commit: r1436373 - /myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Author: lofwyr
Date: Mon Jan 21 14:35:06 2013
New Revision: 1436373

URL: http://svn.apache.org/viewvc?rev=1436373&view=rev
Log:
TOBAGO-1207: Codi WindowScope: when opening a new Window the windowId must be attached to it

Modified:
    myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1436373&r1=1436372&r2=1436373&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon Jan 21 14:35:06 2013
@@ -2660,4 +2660,51 @@ Tobago.registerListener(Tobago.File.init
 
 // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+Tobago.Codi = {};
+
+/**
+ * If the window has no name set we set the name and request a new view with unset windowId, so that the
+ * server will generate a new one for us.
+ */
+Tobago.Codi.init = function() {
+
+  var form = document.forms[0];
+  var windowIdEnabled = Tobago.Codi.hasUrlWindowId(form.action);
+  if (windowIdEnabled && window.name == "") {
+    form.action = Tobago.Codi.urlWithoutWindowId(form.action);
+    window.name = "window";
+    Tobago.submitAction();
+  }
+};
+
+Tobago.Codi.hasUrlWindowId = function(base) {
+  return base.indexOf("?windowId=") > -1 || base.indexOf("&windowId=") > -1;
+};
+
+/**
+ * taken from myfaces-extcdi (Codi)
+ */
+Tobago.Codi.urlWithoutWindowId = function(query) {
+    var vars = query.split(/&|\?/g);
+    var newQuery = "";
+    var iParam = 0;
+    for (var i=0; vars != null && i < vars.length; i++) {
+        var pair = vars[i].split("=");
+        if (pair.length == 1) {
+            newQuery = pair[0];
+        }
+        else {
+            if (pair[0] != "windowId") {
+                var amp = iParam++ > 0 ? "&" : "?";
+                newQuery =  newQuery + amp + pair[0] + "=" + pair[1];
+            }
+        }
+    }
+    return newQuery;
+};
+
+Tobago.registerListener(Tobago.Codi.init, Tobago.Phase.DOCUMENT_READY);
+
+// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 TbgTimer.endTbgJs = new Date(); // @DEV_ONLY