You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/03/15 11:40:47 UTC

svn commit: r923161 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_LangUtils.js _util/_Utils.js core/jsf_impl.js xhrCore/_AjaxUtils.js

Author: werpu
Date: Mon Mar 15 10:40:46 2010
New Revision: 923161

URL: http://svn.apache.org/viewvc?rev=923161&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2599

Ok the issue cannot fully be resolved on this level since mojarra has some bypass code added and has bent the spec probably as well. But I added some helper code which can ease the integration. If a second element is present in our form which has the name of the original one
a form now can be determined cleanly and no error is thrown anymore.

Following code now works and still everything should be spec compliant:


    <h:form id="testForm">
        <h:inputText id="test" value="#{myBean.test}">
                  <f:ajax render="test2"/>
        </h:inputText>
        <input type="text" name="testForm:test" value="ccc" />
        <h:inputText id="test2" value="#{myBean.test}"/>
    </h:form>
    <script type="text/javascript">
        //<![CDATA[
        var myTest = document.getElementById("testForm:test");
        myTest.parentNode.removeChild(myTest);
        myTest.onchange();
        //]]>
    </script>


That is what pretty much all component sets do, they replace their original elements either with one with the same identifier or with one with a different identifer and the same name, I simulated that by keeping an element with the same name under the form.
(same identifier never have been a problem but normally it is same name, different identifier and the original element is detached)






Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js?rev=923161&r1=923160&r2=923161&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js Mon Mar 15 10:40:46 2010
@@ -12,48 +12,51 @@
  *  limitations under the License.
  *  under the License.
  */
+if ('undefined' == typeof myfaces || null == myfaces) {
+    var myfaces = null;
+}
 
-var myfaces = null;
-/**
- * A simple provide function
- * fixing the namespaces
- */
-function _reserveMyfacesNamespaces() {
+if ('undefined' == typeof _reserveMyfacesNamespaces || _reserveMyfacesNamespaces == null) {
     /**
-     *
-     * reserve the namespaces used by the myfaces core
+     * A simple provide function
+     * fixing the namespaces
      */
-    //we have not registered the namespace with openajax so we dont do it for now
-
-    //if ('undefined' != typeof OpenAjax && ( 'undefined' == typeof myfaces || null == myfaces)) {
-    //    OpenAjax.hub.registerLibrary("myfaces", "myfaces.apache.org", "1.0", null);
-    //}
+    var _reserveMyfacesNamespaces = function() {
+        /**
+         *
+         * reserve the namespaces used by the myfaces core
+         */
+        //we have not registered the namespace with openajax so we dont do it for now
 
-    /*originally we had it at org.apache.myfaces, but we are now down to myfaces since the openajax seems to have problems registering more than a root domain and org is not only apache specific*/
-    if('undefined' == typeof myfaces || null == myfaces) {
-        myfaces = new Object();
-    }
+        //if ('undefined' != typeof OpenAjax && ( 'undefined' == typeof myfaces || null == myfaces)) {
+        //    OpenAjax.hub.registerLibrary("myfaces", "myfaces.apache.org", "1.0", null);
+        //}
 
-    if('undefined' == typeof(myfaces._impl) || null == myfaces._impl) {
-        myfaces._impl = new Object();
-    }
+        /*originally we had it at org.apache.myfaces, but we are now down to myfaces since the openajax seems to have problems registering more than a root domain and org is not only apache specific*/
+        if ('undefined' == typeof myfaces || null == myfaces) {
+            myfaces = new Object();
+        }
 
-    if('undefined' == typeof(myfaces._impl._util) || null == myfaces._impl._util) {
-        myfaces._impl._util = new Object();
-    }
-    if('undefined' == typeof(myfaces._impl.core) || null == myfaces._impl.core) {
-        myfaces._impl.core = new Object();
-    }
-    if('undefined' == typeof(myfaces._impl.xhrCore) || null == myfaces._impl.xhrCore) {
-        myfaces._impl.xhrCore = new Object();
-    }
-    if('undefined' == typeof(myfaces.config) || null == myfaces.config) {
-        myfaces.config = new Object();
-    }
+        if ('undefined' == typeof(myfaces._impl) || null == myfaces._impl) {
+            myfaces._impl = new Object();
+        }
 
-}
+        if ('undefined' == typeof(myfaces._impl._util) || null == myfaces._impl._util) {
+            myfaces._impl._util = new Object();
+        }
+        if ('undefined' == typeof(myfaces._impl.core) || null == myfaces._impl.core) {
+            myfaces._impl.core = new Object();
+        }
+        if ('undefined' == typeof(myfaces._impl.xhrCore) || null == myfaces._impl.xhrCore) {
+            myfaces._impl.xhrCore = new Object();
+        }
+        if ('undefined' == typeof(myfaces.config) || null == myfaces.config) {
+            myfaces.config = new Object();
+        }
 
-_reserveMyfacesNamespaces();
+    };
+    _reserveMyfacesNamespaces();
+};
 
 /**
  * Central internal JSF2 LangUtils with code used
@@ -65,7 +68,7 @@ _reserveMyfacesNamespaces();
  */
 if ('undefined' == typeof(myfaces._impl._util._LangUtils) || null == myfaces._impl._util._LangUtils) {
     myfaces._impl._util._LangUtils = function() {
-        }
+    }
 
     myfaces._impl._util._LangUtils.global = this;
 
@@ -76,9 +79,8 @@ if ('undefined' == typeof(myfaces._impl.
         return this._underTest;
     };
 
-
     myfaces._impl._util._LangUtils.byId = function(/*object*/ reference) {
-        if(myfaces._impl._util._LangUtils.isString(reference)) {
+        if (myfaces._impl._util._LangUtils.isString(reference)) {
             return document.getElementById(reference);
         }
         return reference;
@@ -97,7 +99,7 @@ if ('undefined' == typeof(myfaces._impl.
      properties in obj are appended at the end of startWith and
      startWith is the returned array.
      */
-    myfaces._impl._util._LangUtils._toArray = function(obj, offset,  startWith) {
+    myfaces._impl._util._LangUtils._toArray = function(obj, offset, startWith) {
         //	summary:
         //		Converts an array-like object (i.e. arguments, DOMCollection) to an
         //		array. Returns a new Array with the elements of obj.
@@ -136,15 +138,15 @@ if ('undefined' == typeof(myfaces._impl.
      * @param {RegExp} splitter our splitter reglar expression
      * @return an array of the splitted string
      */
-    myfaces._impl._util._LangUtils.strToArray = function(/*string*/ it,/*regexp*/ splitter) {
+    myfaces._impl._util._LangUtils.strToArray = function(/*string*/ it, /*regexp*/ splitter) {
         //	summary:
         //		Return true if it is a String
 
-        if(!myfaces._impl._util._LangUtils.isString(it)) {
+        if (!myfaces._impl._util._LangUtils.isString(it)) {
             throw Error("myfaces._impl._util._LangUtils.strToArray param not of type string");
         }
         var resultArr = it.split(splitter);
-        for(var cnt = 0; cnt < resultArr.length; cnt++) {
+        for (var cnt = 0; cnt < resultArr.length; cnt++) {
             resultArr[cnt] = myfaces._impl._util._LangUtils.trim(resultArr[cnt]);
         }
         return resultArr;
@@ -158,8 +160,8 @@ if ('undefined' == typeof(myfaces._impl.
     myfaces._impl._util._LangUtils.trim = function(/*string*/ str) {
 
         str = str.replace(/^\s\s*/, ''),
-        ws = /\s/,
-        i = str.length;
+                ws = /\s/,
+                i = str.length;
         while (ws.test(str.charAt(--i)));
         return str.slice(0, i + 1);
     };
@@ -175,8 +177,6 @@ if ('undefined' == typeof(myfaces._impl.
         return arr[arr.length - 1];
     };
 
-    
-
     /**
      * Backported from dojo
      * a failsafe string determination method
@@ -249,13 +249,12 @@ if ('undefined' == typeof(myfaces._impl.
      * @deprecated will be removed soon
      */
     myfaces._impl._util._LangUtils._getLogger = function() {
-        if(null ==  myfaces._impl._util._LangUtils._logger) {
+        if (null == myfaces._impl._util._LangUtils._logger) {
             myfaces._impl._util._LangUtils._logger = myfaces._impl._util._Logger.getInstance();
         }
         return myfaces._impl._util._LangUtils._logger;
     };
 
-
     myfaces._impl._util._LangUtils._hitchArgs = function(scope, method /*,...*/) {
         var pre = this._toArray(arguments, 2);
         var named = this.isString(method);
@@ -269,7 +268,6 @@ if ('undefined' == typeof(myfaces._impl.
         } // Function
     };
 
-
     /**
      * Helper function to merge two maps
      * into one
@@ -285,27 +283,27 @@ if ('undefined' == typeof(myfaces._impl.
         var result = {};
         var keyIdx = {};
         var key = null;
-        for(key in source) {
+        for (key in source) {
             /**
-           *we always overwrite dest with source
-           *unless overWrite is not set or source does not exist
-           *but also only if dest exists otherwise source still is taken
-           */
-            if(!overwriteDest) {
+             *we always overwrite dest with source
+             *unless overWrite is not set or source does not exist
+             *but also only if dest exists otherwise source still is taken
+             */
+            if (!overwriteDest) {
                 /**
                  *we use exists instead of booleans because we cannot reloy
                  *on all values being non boolean, we would need an elvis
                  *operator in javascript to shorten this :-(
                  */
-                result[key] = _JSF2Utils.exists(dest,key) ? dest[key] : source[key];
+                result[key] = _JSF2Utils.exists(dest, key) ? dest[key] : source[key];
             } else {
-                result[key] = _JSF2Utils.exists(source,key) ? source[key] : dest[key];
+                result[key] = _JSF2Utils.exists(source, key) ? source[key] : dest[key];
             }
             keyIdx[key] = true;
         }
-        for(key in destination) {
+        for (key in destination) {
             /*if result.key does not exist we push in dest.key*/
-            result[key] = _JSF2Utils.exists(result,key) ? result[key] : destination[key];
+            result[key] = _JSF2Utils.exists(result, key) ? result[key] : destination[key];
         }
         return result;
     };
@@ -314,17 +312,16 @@ if ('undefined' == typeof(myfaces._impl.
      * check if an element exists in the root
      */
     myfaces._impl._util._LangUtils.exists = function(root, element) {
-        return ('undefined' != typeof root && null != root &&  'undefined' != typeof root[element] && null != root[element]);
+        return ('undefined' != typeof root && null != root && 'undefined' != typeof root[element] && null != root[element]);
     }
 
-
     /**
      * checks if an array contains an element
      * @param {Array} arr   array
      * @param {String} string_name string to check for
      */
     myfaces._impl._util._LangUtils.arrayContains = function(arr, string_name) {
-        for ( var loop = 0; loop < arr.length; loop++) {
+        for (var loop = 0; loop < arr.length; loop++) {
             if (arr[loop] == string_name) {
                 return true;
             }
@@ -343,14 +340,14 @@ if ('undefined' == typeof(myfaces._impl.
      * and functionalitywise dirty
      */
     myfaces._impl._util._LangUtils.arrayToString = function(/*String or array*/ arr, /*string*/ delimiter) {
-        if( myfaces._impl._util._LangUtils.isString(arr) ) {
+        if (myfaces._impl._util._LangUtils.isString(arr)) {
             return arr;
         }
         var finalDelimiter = (null == delimiter) ? "\n" : delimiter;
 
         var resultArr = [];
-        for(var cnt = 0; cnt < arr.length; cnt ++) {
-            if(myfaces._impl._util._LangUtils.isString(arr[cnt])) {
+        for (var cnt = 0; cnt < arr.length; cnt ++) {
+            if (myfaces._impl._util._LangUtils.isString(arr[cnt])) {
                 resultArr.push(((delimiter == null) ? ("[" + cnt + "] ") : "") + arr[cnt]);
             } else {
                 resultArr.push(((delimiter == null) ? ("[" + cnt + "] ") : "") + arr[cnt].toString());

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=923161&r1=923160&r2=923161&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Mon Mar 15 10:40:46 2010
@@ -217,7 +217,6 @@ if (!myfaces._impl._util._LangUtils.exis
         item.parentNode.removeChild(item);
     }
 
-  
     /**
      * [STATIC]
      * Replaces HTML elements through others
@@ -266,7 +265,6 @@ if (!myfaces._impl._util._LangUtils.exis
             // and remove the old item, in case of an empty newtag and do nothing else
             item.parentNode.removeChild(item);
 
-
         } catch (e) {
             myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "replaceHTMLItem", e);
         }
@@ -341,12 +339,12 @@ if (!myfaces._impl._util._LangUtils.exis
             for (var loop = 0; loop < styleEntries.length; loop++) {
                 var keyVal = styleEntries[loop].split(":");
                 if (keyVal[0] != "" && keyVal[0] == "opacity") {
-                  //special ie quirks handling for opacity
-                    
-                  var opacityVal = Math.max(100, Math.round(parseFloat( keyVal[1] ) * 10)); 
-                  domNode.style.setAttribute("filter","alpha(opacity="+opacityVal+")");
-                  //if you need more hacks I would recommend
-                  //to use the class attribute and conditional ie includes!
+                    //special ie quirks handling for opacity
+
+                    var opacityVal = Math.max(100, Math.round(parseFloat(keyVal[1]) * 10));
+                    domNode.style.setAttribute("filter", "alpha(opacity=" + opacityVal + ")");
+                    //if you need more hacks I would recommend
+                    //to use the class attribute and conditional ie includes!
                 } else if (keyVal[0] != "") {
                     domNode.style.setAttribute(keyVal[0], keyVal[1]);
                 }
@@ -462,6 +460,103 @@ if (!myfaces._impl._util._LangUtils.exis
     };
 
     /**
+     * fuzzy form detection which tries to determine the form
+     * an item has been detached.
+     *
+     * The problem is some Javascript libraries simply try to
+     * detach controls and controls others by reusing the names
+     * of the detached input controls. The thing is most of the times,
+     * the name is unique in a jsf scenario due to the inherent form mappig
+     * one way or the other, we will try to fix that by
+     * identifying the proper form over the name
+     *
+     * We do it three way, in case of no form null is returned
+     * in case of a single form no further detection is needed
+     * in case of multiple forms we check all elements with a given name (which we determine
+     * out of a name or id of the detached element) and then iterate over them
+     * to find whether they are in a form or not.
+     *
+     * We cannot do much further because in case of two identical named elements
+     * all checks must fail and the first elements form is served.
+     *
+     * Note, this method is only triggered in case of the issuer or an ajax request
+     * is a detached element, otherwise already existing code has served the correct form.
+     *
+     * This method was added because of
+     * https://issues.apache.org/jira/browse/MYFACES-2599
+     * to support the integration of existing ajax libraries which do heavy dom manipulation on the
+     * controls side (Dojos Dijit library for instance).
+     *
+     * @param {XMLHTTPRequest} request
+     * @param {Map} context
+     * @param {HtmlElement} item - child element
+     *
+     * @return either null or a form node if it could be determined
+     */
+    myfaces._impl._util._Utils.fuzzyFormDetection = function(request, context, item) {
+        if (0 == document.forms.length) {
+            return null;
+        } else if (1 == document.forms.length) {
+            return document.forms[0];
+        }
+
+        //else
+        var name = item.name;
+        var id = item.id;
+
+        var submitIdentifier = ('undefined' == typeof name || null == name) ? id : name;
+        if ('undefined' == typeof submitIdentifier || null == submitIdentifier) {
+            //no identifier found we give it a shot with the first form
+            return document.forms[0];
+        }
+
+        /**
+         * highest chance is to find an element with an identifier
+         */
+        var elementById = document.getElementById(submitIdentifier);
+        var foundElements = new Array();
+        if (null != elementById) {
+            if ('undefined' == typeof element.name || null == element.name || submitIdentifier == element.name) {
+                foundElements.push(elementById);
+            }
+        }
+
+        /**
+         * the lesser chance is the elements which have the same name
+         * (which is the more likely case in case of a brute dom replacement)
+         */
+        var namedFoundElements = document.getElementsByName(submitIdentifier);
+        if (null != namedFoundElements) {
+            for (var cnt = 0; cnt < namedFoundElements.length; cnt++) {
+                //concat() does not work out here due to array not directly equals to [] in some browsers
+                foundElements.push(namedFoundElements[cnt]);
+            }
+        }
+
+        if (null == foundElements || 0 == foundElements.length) {
+            return null;
+        }
+
+        //we now iterate over all possible elements with the identifier element being the first if present
+        //however if the identifier element has no parent form we must rely on our found named elements
+        //to have at least one parent form
+        for (var cnt = 0; cnt < foundElements.length; cnt++) {
+            var foundElement = foundElements[cnt];
+            var parentItem = ('undefined' != typeof foundElement && null != foundElement) ? foundElement.parentNode : null;
+            while (parentItem != null
+                    && parentItem.tagName.toLowerCase() != "form") {
+                parentItem = parentItem.parentNode;
+            }
+            if (parentItem != null) {
+                return parentItem;
+            }
+        }
+
+        //nothing found, fallback, first form in the system, which was the original behavior
+        return document.forms[0];
+    };
+
+    /**
      * [STATIC]
      * gets a parent of an item with a given tagname
      * @param {XMLHTTPRequest} request
@@ -470,9 +565,20 @@ if (!myfaces._impl._util._LangUtils.exis
      * @param {String} parentName - TagName of parent element
      */
     myfaces._impl._util._Utils.getParent = function(request, context, item, parentName) {
-        try {
-            // parent tag parentName suchen
-            var parentItem = item.parentNode;
+
+		try {
+            if('undefined' == typeof item || null == item) {
+			    throw Error("myfaces._impl._util._Utils.getParen: item is null or undefined,this not allowed");
+		    }
+
+            //search parent tag parentName
+            var parentItem = ('undefined' != typeof item.parentNode) ? item.parentNode: null;
+
+
+            if ('undefined' != typeof item.tagName && null != item.tagName && item.tagName.toLowerCase() == parentName) {
+                return item;
+            }
+
             while (parentItem != null
                     && parentItem.tagName.toLowerCase() != parentName) {
                 parentItem = parentItem.parentNode;
@@ -480,8 +586,9 @@ if (!myfaces._impl._util._LangUtils.exis
             if (parentItem != null) {
                 return parentItem;
             } else {
+                //we issue a warning but proceed with a fuzzy search in case of a form later
                 myfaces._impl.xhrCore._Exception.throwNewWarning
-                        (request, context, "Utils", "getParent", "The item has no parent with type <" + parentName + ">");
+                        (request, context, "Utils", "getParent", "The item has no parent with type <" + parentName + "> it might be outside of the parent or generally detached. ");
                 return null;
             }
         } catch (e) {
@@ -491,7 +598,7 @@ if (!myfaces._impl._util._LangUtils.exis
 
     /**
      * [STATIC]
-     * gets the child of an item with a given tagname
+     * gets the child of an item with a given tag name
      * @param {HtmlElement} item - parent element
      * @param {String} childName - TagName of child element
      * @param {String} itemName - name-Attribut the child can have (can be null)
@@ -541,9 +648,9 @@ if (!myfaces._impl._util._LangUtils.exis
             return;
         } else if (undefined != typeof (window.eval) && null != window.eval) {
 
-            //fixup for a mozilla bug, a bug in mozilla prevents, that the window is properly applied
+            //fix for a Mozilla bug, a bug, Mozilla prevents, that the window is properly applied
             //the former approach was to scope an outer anonymouse function but the scoping is not necessary
-            //mozilla behaves correctly if you just add an outer function, then the window scope is again
+            //Mozilla behaves correctly if you just add an outer function, then the window scope is again
             //accepted as the real scope
             var func = function () {
                 window.eval.call(window, code);
@@ -585,12 +692,12 @@ if (!myfaces._impl._util._LangUtils.exis
      * @param {Node} node the node to concat its blocks for
      */
     myfaces._impl._util._Utils.concatCDATABlocks = function(/*Node*/ node) {
-       var cDataBlock = [];
-       // response may contain several blocks
-       for (var i = 0; i < node.childNodes.length; i++) {
-           cDataBlock.push( node.childNodes[i].data);
-       }
-       return cDataBlock.join('');
+        var cDataBlock = [];
+        // response may contain several blocks
+        for (var i = 0; i < node.childNodes.length; i++) {
+            cDataBlock.push(node.childNodes[i].data);
+        }
+        return cDataBlock.join('');
     };
 
     myfaces._impl._util._Utils.browserDetection();

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=923161&r1=923160&r2=923161&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Mon Mar 15 10:40:46 2010
@@ -153,6 +153,12 @@ if (!myfaces._impl._util._LangUtils.exis
          *all the time
          **/
         var JSF2Utils = myfaces._impl._util._LangUtils;
+        var elementId = null;
+        if(JSF2Utils.isString(element)) {
+            elementId = element;
+        } else if ('undefined' != typeof element && null != element) {
+            elementId = element.id;
+        }
 
         /**
          * we cross reference statically hence the mapping here
@@ -161,7 +167,9 @@ if (!myfaces._impl._util._LangUtils.exis
         element = JSF2Utils.byId(element);
 
         /*assert a valid structure of a given element*/
-        this._assertElement(element);
+        //element can be mapped out by the time of passing the request by some underlying framework
+        //this._assertElement(element);
+
         /*assert if the onerror is set and once if it is set it must be of type function*/
         this._assertFunction(options.onerror);
         /*assert if the onevent is set and once if it is set it must be of type function*/
@@ -197,16 +205,19 @@ if (!myfaces._impl._util._LangUtils.exis
         /**
          * fetch the parent form
          */
-        var sourceForm = myfaces._impl._util._Utils.getParent(null, ajaxContext, element, "form");
+        var sourceForm = ('undefined' != typeof element && null != element) ? myfaces._impl._util._Utils.getParent(null, ajaxContext, element, "form") : null;
 
         if ('undefined' == typeof sourceForm || null == sourceForm) {
-            sourceForm = document.forms[0];
+            //in case of a detached element we have to try to determine fuzzily over the name/id attribute
+            //  which form we have to use
+            //this should get in 90% of all usecases with multiple forms the form right
+            sourceForm = myfaces._impl._util._Utils.fuzzyFormDetection(null, ajaxContext, element);
         }
 
         /**
          * binding contract the javax.faces.source must be set
          */
-        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE] = element.id;
+        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE] = elementId;
 
         /**
          * javax.faces.partial.ajax must be set to true
@@ -225,7 +236,7 @@ if (!myfaces._impl._util._LangUtils.exis
             var execAll = execString.indexOf(this._OPT_IDENT_ALL) != -1;
             if (!execNone && !execAll) {
                 execString = execString.replace(this._OPT_IDENT_FORM, sourceForm.id);
-                execString = execString.replace(this._OPT_IDENT_THIS, element.id);
+                execString = execString.replace(this._OPT_IDENT_THIS, elementId);
 
                 passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = execString;
             } else if (execAll) {
@@ -236,7 +247,7 @@ if (!myfaces._impl._util._LangUtils.exis
             /*remap just in case we have a valid pointer to an existing object*/
             delete passThroughArguments.execute;
         } else {
-            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = element.id;
+            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = elementId;
         }
 
         if (JSF2Utils.exists(passThroughArguments, "render")) {
@@ -245,7 +256,7 @@ if (!myfaces._impl._util._LangUtils.exis
             var renderAll = renderString.indexOf(this._OPT_IDENT_ALL) != -1;
             if (!renderNone && !renderAll) {
                 renderString = renderString.replace(this._OPT_IDENT_FORM, sourceForm.id);
-                renderString = renderString.replace(this._OPT_IDENT_THIS, element.id);
+                renderString = renderString.replace(this._OPT_IDENT_THIS, elementId);
                 passThroughArguments[myfaces._impl.core._jsfImpl._PROP_RENDER] = renderString;
                 passThroughArguments.render = null;
             } else if (renderAll) {

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=923161&r1=923160&r2=923161&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Mon Mar 15 10:40:46 2010
@@ -65,7 +65,7 @@ if (!myfaces._impl._util._LangUtils.exis
             }
 
             // if triggered by a Button send it along
-            if (item.type != null && item.type.toLowerCase() == "submit") {
+            if ('undefined' != typeof item && null != item && item.type != null && item.type.toLowerCase() == "submit") {
                 stringBuffer[stringBuffer.length] = encodeURIComponent(item.name);
                 stringBuffer[stringBuffer.length] = "=";
                 stringBuffer[stringBuffer.length] = encodeURIComponent(item.value);