[portal-commits] JBoss Portal SVN: r13028 - branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Mar 13 09:36:38 EDT 2009


Author: thomas.heute at jboss.com
Date: 2009-03-13 09:36:38 -0400 (Fri, 13 Mar 2009)
New Revision: 13028

Modified:
   branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/dyna.js
   branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/prototype.js
Log:
JBEPP-42: Several submit buttons in a form don't work with partial refresh enabled

Modified: branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/dyna.js
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/dyna.js	2009-03-13 13:10:04 UTC (rev 13027)
+++ branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/dyna.js	2009-03-13 13:36:38 UTC (rev 13028)
@@ -1,4 +1,30 @@
-function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId) {
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+
+var currentSubmit;
+
+function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId)
+{
    var options = {
       requestHeaders: ["ajax","true","bilto","toto"],
       method: "post",
@@ -17,7 +43,7 @@
       onLoading: function(t)
       {
       }
-   }
+   };
    new Ajax.Request(server_base_url + "/ajax", options);
 }
 
@@ -78,6 +104,11 @@
    var source = Event.element(event);
    var container = Element.up(source, "div.dyna-window");
 
+   //attach onclick observer to all submit buttons
+   $$('input[type=submit]').invoke('observe', 'click', function(e) {
+      currentSubmit = e.findElement();
+   });
+
    // We found the window
    if (container != null) {
 
@@ -123,7 +154,6 @@
 
                   // Check we can handle this URL
                   if (isURLAccepted(current.action)) {
-
                      // Set URL
                      url = current.action;
 
@@ -131,7 +161,7 @@
                      options.enctype = enctype;
                      options.asynchronous = false;
                      options.method = "post"
-                     options.postBody = Form.serialize(current);
+                     options.postBody = Form.serialize(current,'',currentSubmit);
                   }
                }
             }

Modified: branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/prototype.js
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/prototype.js	2009-03-13 13:10:04 UTC (rev 13027)
+++ branches/Enterprise_Portal_Platform_4_3/theme/src/bin/portal-ajax-war/dyna/prototype.js	2009-03-13 13:36:38 UTC (rev 13028)
@@ -2609,7 +2609,9 @@
       "FORM":     Object.clone(Form.Methods),
       "INPUT":    Object.clone(Form.Element.Methods),
       "SELECT":   Object.clone(Form.Element.Methods),
-      "TEXTAREA": Object.clone(Form.Element.Methods)
+      "TEXTAREA": Object.clone(Form.Element.Methods),
+       //[SERIALIZE_ERROR]
+      "BUTTON":   Object.clone(Form.Element.Methods)
     });
   }
 
@@ -3475,8 +3477,21 @@
 };
 
 Form.Methods = {
-  serialize: function(form, options) {
-    return Form.serializeElements(Form.getElements(form), options);
+  serialize: function(form, options, buttonPressed) {
+  //[SERIALIZE_ERROR] Implements additional functionality to support <button> and ensure other button-type
+  // <inputs> are not serialized
+  var elements = Form.getElements(form);
+    if (buttonPressed) {
+       elements = elements.findAll(
+         function(element) {
+           return element == $(buttonPressed) ||
+             (element.tagName.toLowerCase() != "button" &&
+             (element.tagName.toLowerCase() != "input" ||
+             (element.type != "submit" && element.type != "button" && element.type != "image" && element.type != "reset")));
+         }
+       );
+     };
+  return Form.serializeElements(elements, options);
   },
 
   getElements: function(form) {
@@ -3657,6 +3672,11 @@
     else element.value = value;
   },
 
+  //[SERIALIZE_ERROR]
+  button: function(element) {
+     return element.value;
+   },
+
   select: function(element, value) {
     if (Object.isUndefined(value))
       return this[element.type == 'select-one' ?




More information about the portal-commits mailing list