You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/08/15 18:38:57 UTC

svn commit: r804484 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/...

Author: bommel
Date: Sat Aug 15 16:38:57 2009
New Revision: 804484

URL: http://svn.apache.org/viewvc?rev=804484&view=rev
Log:
(TOBAGO-786) Page submit on window resize
thanks to Helmut Swaczinna for the initial patch

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
    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

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Facets.java?rev=804484&r1=804483&r2=804484&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Facets.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Facets.java Sat Aug 15 16:38:57 2009
@@ -37,6 +37,7 @@
   public static final String PICKER_POPUP = "pickerPopup";
   public static final String POPUP = "popup";
   public static final String RELOAD = "reload";
+  public static final String RESIZE_ACTION = "resizeAction";
   public static final String SORTER = "sorter";
   public static final String TOOL_BAR = "toolBar";
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java?rev=804484&r1=804483&r2=804484&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java Sat Aug 15 16:38:57 2009
@@ -39,11 +39,16 @@
     uiComponentBaseClass = "org.apache.myfaces.tobago.component.AbstractUIPage",
     rendererType = RendererTypes.PAGE,
     facets =
-        { @Facet(name = Facets.ACTION, description ="Contains an instance of UICommand (tc:command) for an auto-action",
+        { @Facet(name = Facets.ACTION,
+                description ="Contains an instance of UICommand (tc:command) for an auto-action",
                 allowedChildComponenents = "org.apache.myfaces.tobago.Command"),
-        @Facet(name = Facets.MENUBAR, description = "Menubar",
+          @Facet(name = Facets.RESIZE_ACTION,
+                description ="Contains an instance of UICommand (tc:command) or a UIForm (tc:form) with a UICommand"
+                    + " for a resize-action",
+                allowedChildComponenents = {"org.apache.myfaces.tobago.Command", "org.apache.myfaces.tobago.Form"}),
+          @Facet(name = Facets.MENUBAR, description = "Menubar",
                 allowedChildComponenents = "javax.faces.component.UIPanel"), //fake
-        @Facet(name=Facets.LAYOUT, description = "Contains an instance of UILayout",
+          @Facet(name=Facets.LAYOUT, description = "Contains an instance of UILayout",
                 allowedChildComponenents = "org.apache.myfaces.tobago.GridLayout")})
 
 public interface PageTagDeclaration

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?rev=804484&r1=804483&r2=804484&view=diff
==============================================================================
--- 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 Sat Aug 15 16:38:57 2009
@@ -23,6 +23,7 @@
 import org.apache.myfaces.tobago.component.AbstractUIPage;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.UIForm;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.context.ClientProperties;
@@ -44,6 +45,7 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UICommand;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
@@ -281,6 +283,19 @@
       }
     }
 
+     if (component.getFacets().containsKey(Facets.RESIZE_ACTION)) {
+      UIComponent facet = component.getFacet(Facets.RESIZE_ACTION);
+      UIComponent command = null;
+      if (facet instanceof UICommand) {
+        command = facet;
+      } else if (facet instanceof UIForm && facet.getChildCount() == 1) {
+        command = (UIComponent) facet.getChildren().get(0);
+      }
+      if (command != null && command.isRendered()) {
+        writer.writeJavascript("Tobago.resizeActionId = '" + command.getClientId(facesContext) + "';");
+      }
+    }
+
     UIComponent menubar = page.getFacet(Facets.MENUBAR);
     if (menubar != null) {
       facesContext.getOnloadScripts().add("Tobago.setElementWidth('"
@@ -478,6 +493,7 @@
           FacesMessage message = (FacesMessage) messages.next();
           logMessages.add(errorMessageForDebugging(id, message));
         }
+        
       }
       if (!logMessages.isEmpty()) {
         logMessages.add(0, "LOG.show();");

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?rev=804484&r1=804483&r2=804484&view=diff
==============================================================================
--- 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 Sat Aug 15 16:38:57 2009
@@ -79,31 +79,31 @@
 
   /**
    * the html body object of current page.
-   * set via init fuction (onload attribute of body)
+   * set via init function (onload attribute of body)
    */
   page: null,
 
   /**
     * The html form object of current page.
-    * set via init fuction (onload attribute of body)
+    * set via init function (onload attribute of body)
     */
   form: null,
 
   /**
     * The hidden html input object for submitted actionId.
-    * set via init fuction (onload attribute of body)
+    * set via init function (onload attribute of body)
     */
   action: null,
 
   /**
    * The hidden html input object for the contextPath.
-   * set via init fuction (onload attribute of body)
+   * set via init function (onload attribute of body)
    */
   contextPath: null,
 
   /**
     * The hidden html input object for partial requests.
-    * set via init fuction (onload attribute of body)
+    * set via init function (onload attribute of body)
     */
   partialRequestIds: null,
 
@@ -117,6 +117,12 @@
 
   lastFocusId: undefined,
 
+  /**
+    * The id of the action which should be executed when the window was resized.
+    */
+  resizeActionId: undefined,
+  resizeEventCount: 0,
+
   htmlIdIndex: 0,
 
   createHtmlId: function() {
@@ -285,6 +291,11 @@
 
     this.addBindEventListener(document, "keypress", this.acceleratorKeys, "observe");
 
+    if (Tobago.resizeActionId) {
+      // firebug submits an onresize event
+      window.setTimeout(Tobago.registerResizeAction, 1000);
+    }
+
     window.setTimeout(Tobago.finishPageLoading, 1);
     if (TbgTimer.endBody) {
       TbgTimer.endOnload = new Date();
@@ -313,6 +324,10 @@
 
   },
 
+  registerResizeAction: function() {
+    Tobago.addEventListener(window, "resize", Tobago.resizePage);
+  },
+
   onSubmit: function() {
     if (Tobago.applicationOnsubmit) {
       var result = Tobago.applicationOnsubmit();
@@ -1178,6 +1193,18 @@
     Tobago.reloadComponent(source, popupId, actionId, options);
   },
 
+  resizePage: function(event) {
+    Tobago.resizeEventCount++;
+    window.setTimeout(Tobago.resizePageAction, 250);
+  },
+
+  resizePageAction: function() {
+    Tobago.resizeEventCount--;
+    if (Tobago.resizeEventCount == 0) {
+      Tobago.submitAction(Tobago.resizeActionId);
+    }
+  },
+
 // -------- Util functions ----------------------------------------------------
 
   clickOnElement: function(id) {