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 2007/01/17 23:38:19 UTC

svn commit: r497215 - in /myfaces/tobago/trunk/theme: charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/ richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image...

Author: lofwyr
Date: Wed Jan 17 14:38:18 2007
New Revision: 497215

URL: http://svn.apache.org/viewvc?view=rev&rev=497215
Log:
TOBAGO-102: Prevent double request 
After a submit, an invisible div will be put before the application, so you can't press any buttons.
After 750 ms the screen will be shaddowed (not working in IE yet)
After 2000 ms there will appear a "please wait" image (should be nicer)

Added:
    myfaces/tobago/trunk/theme/charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/
    myfaces/tobago/trunk/theme/charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/tobago-overlay-background.png   (with props)
    myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/tobago-overlay-background.png   (with props)
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-background.png   (with props)
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-wait.gif   (with props)
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tobago-overlay-background.png   (with props)
Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Added: myfaces/tobago/trunk/theme/charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/tobago-overlay-background.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/tobago-overlay-background.png?view=auto&rev=497215
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/charlotteville/src/main/resources/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/image/tobago-overlay-background.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/tobago-overlay-background.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/tobago-overlay-background.png?view=auto&rev=497215
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/tobago-overlay-background.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?view=diff&rev=497215&r1=497214&r2=497215
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Wed Jan 17 14:38:18 2007
@@ -298,9 +298,17 @@
     writer.writeComponentClass();
     writer.writeIdAttribute(clientId);
 
-    String blank = ResourceManagerUtil.getImageWithPath(facesContext, "image/blank.gif");
-
-    HtmlRendererUtil.writeJavascript(writer, "Tobago.pngFixBlankImage = \"" + blank + "\";");
+    StringBuilder images = new StringBuilder();
+    images.append("Tobago.pngFixBlankImage = '");
+    images.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/blank.gif"));
+    images.append("';\n");
+    images.append("Tobago.OVERLAY_BACKGROUND = '");
+    images.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/tobago-overlay-background.png"));
+    images.append("';\n");
+    images.append("Tobago.OVERLAY_WAIT = '");
+    images.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/tobago-overlay-wait.gif"));
+    images.append("';\n");
+    HtmlRendererUtil.writeJavascript(writer, images.toString());
 
       if (debugMode) {
       final String[] jsFiles = new String[] {
@@ -308,8 +316,7 @@
           "script/dragdrop.js",
           "script/logging.js"
       };
-      final String[] jsCommand
-          = new String[]{"new LOG.LogArea({hide: " + hideClientLogging + "});"};
+      final String[] jsCommand = new String[]{"new LOG.LogArea({hide: " + hideClientLogging + "});"};
       HtmlRendererUtil.writeScriptLoader(facesContext, jsFiles, jsCommand);
     }
     HtmlRendererUtil.writeJavascript(writer, "TbgTimer.startBody = new Date();");

Added: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-background.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-background.png?view=auto&rev=497215
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-background.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-wait.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-wait.gif?view=auto&rev=497215
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tobago-overlay-wait.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tobago-overlay-background.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tobago-overlay-background.png?view=auto&rev=497215
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tobago-overlay-background.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?view=diff&rev=497215&r1=497214&r2=497215
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Wed Jan 17 14:38:18 2007
@@ -245,16 +245,62 @@
   },
 
   onSubmit: function() {
-    if (!this.isSubmit) {
-      this.isSubmit = true;
-      var clientDimension
-          = this.createInput("hidden", this.form.id + '-clientDimension');
-      clientDimension.value
-          = document.body.clientWidth + ";" + document.body.clientHeight;
-      this.form.appendChild(clientDimension);
+    this.isSubmit = true;
+    var clientDimension = this.createInput("hidden", this.form.id + '-clientDimension');
+    clientDimension.value = document.body.clientWidth + ";" + document.body.clientHeight;
+    this.form.appendChild(clientDimension);
+  },
+
+  onBeforeUnload: function() {
+    Tobago.createOverlay(Tobago.page);
+    setTimeout(Tobago.makeOverlaySemitransparent, 750);
+    setTimeout(Tobago.makeOverlayWait, 2000);
+  },
+
+  makeOverlaySemitransparent: function() {
+    var overlay = Tobago.element(Tobago.page.id + "-overlay");
+    if (overlay) {
+      var img = document.createElement("IMG");
+      img.style.width = overlay.clientWidth;
+      img.style.height = overlay.clientHeight;
+//      todo: implement ie 6 workaround for alpha images
+      if (!Tobago.fixImage) { // is IE
+        img.src = Tobago.OVERLAY_BACKGROUND;
+      }
+      overlay.appendChild(img);
     }
   },
 
+  makeOverlayWait: function() {
+    var overlay = Tobago.element(Tobago.page.id + "-overlay");
+    if (overlay) {
+      var table = document.createElement("TABLE");
+      table.style.position = "absolute";
+      table.style.top = "0px";
+      table.style.left = "0px";
+      table.border = 1;
+      table.cellPadding = 0;
+      table.cellSpacing = 0;
+      table.style.width = "100%";
+      table.style.height = "100%";
+
+      var row = table.insertRow(0);
+      var cell = row.insertCell(0);
+      cell.align = "center";
+      cell.width = "100%";
+      var anim = document.createElement("IMG");
+      anim.id = Tobago.page.id + "-overlay-wait";
+      cell.appendChild(anim);
+      overlay.appendChild(table);
+      setTimeout(Tobago.loadOverlayWait, 0);
+    }
+  },
+
+  loadOverlayWait: function() {
+    var img = Tobago.element(Tobago.page.id + "-overlay-wait");
+    img.src = Tobago.OVERLAY_WAIT;
+  },
+
   /**
     * Wrapper function to call application generated onunload function
     */
@@ -361,6 +407,20 @@
     */
   submitAction: function(actionId, target) {
     Tobago.Transport.request(function() {
+<<<<<<< .mine
+      if (!this.isSubmit) {
+        this.isSubmit = true;
+        var req = Tobago.Transport.requests.shift(); // remove this from queue
+        LOG.debug("request removed :" + req.toString());
+        var oldAction = Tobago.action.value;
+        Tobago.action.value = actionId;
+        Tobago.onSubmit();
+  //      LOG.debug("submit form with action: " + Tobago.action.value);
+        Tobago.form.submit();
+        Tobago.action.value = oldAction;
+        Tobago.onBeforeUnload();
+      }
+=======
       var req = Tobago.Transport.requests.shift(); // remove this from queue
       LOG.debug("request removed :" + req.toString());
       var oldAction = Tobago.action.value;
@@ -373,6 +433,7 @@
 //      LOG.debug("submit form with action: " + Tobago.action.value);
       Tobago.form.submit();
       Tobago.action.value = oldAction;
+>>>>>>> .r497208
       if (target) {
         Tobago.form.target = oldTarget;
       }
@@ -1020,8 +1081,8 @@
     overlay.style.position = "absolute";
     overlay.style.top = "0px";
     overlay.style.left = "0px";
-    overlay.style.width = element.offsetWidth + 'px';
-    overlay.style.height = element.offsetHeight + 'px';
+    overlay.style.width = element.clientWidth + 'px';
+    overlay.style.height = element.clientHeight + 'px';
     overlay.style.cursor = "wait";
     // TODO: better z-index strategy
     overlay.style.zIndex = 10000;