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/08/16 10:03:57 UTC

svn commit: r985823 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/ExtDom.js _util/_Dom.js _util/_Lang.js _util/_Queue.js core/Impl.js core/_Runtime.js oamSubmit.js xhrCore/_AjaxRequest.js xhrCore/_AjaxResponse.js

Author: werpu
Date: Mon Aug 16 08:03:56 2010
New Revision: 985823

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


Added:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ExtDom.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js
Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js

Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ExtDom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ExtDom.js?rev=985823&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ExtDom.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ExtDom.js Mon Aug 16 08:03:56 2010
@@ -0,0 +1,250 @@
+myfaces._impl.core._Runtime.singletonExtendClass("myfaces._impl._util._ExtDom", myfaces._impl._util._Dom, {
+
+    _Lang:myfaces._impl._util._Lang,
+    _RT:myfaces._impl.core._Runtime,
+
+    /**
+     * finds the elements by an attached style class
+     *
+     * @param fragment the source fragment which is the root of our search (included in the search)
+     * @param styleClass the styleclass to search for
+     * @param deepScan if set to true a deep scan can be performed
+     */
+    findByStyleClass : function(fragment, styleClass, deepScan) {
+        var filter = this._Lang.hitch(this, function(node) {
+            var classes = this.getClasses(node);
+            var len = classes.length;
+            if (len == 0) return false;
+            else {
+                for (var cnt = 0; cnt < len; cnt++) {
+                    if (classes[cnt] === styleClass) return true;
+                }
+            }
+            return false;
+        });
+        try {
+            deepScan = !!deepScan;
+
+            //html5 getElementsByClassname
+
+            //TODO implement this
+            /*if (fragment.getElementsByClassName && deepScan) {
+             return fragment.getElementsByClassName(styleClass);
+             }
+
+             //html5 speed optimization for browsers which do not ,
+             //have the getElementsByClassName implemented
+             //but only for deep scan and normal parent nodes
+             else */
+            if (this._Lang.exists(fragment, "querySelectorAll") && deepScan) {
+                try {
+                    var result = fragment.querySelectorAll("." + styleClass.replace(/\./g, "\\."));
+
+                    if (fragment.nodeType == 1 && filter(fragment)) {
+                        result = (result == null) ? [] : result;
+                        result = this._Lang.objToArray(result);
+                        result.push(fragment);
+                    }
+                    return result;
+                } catch(e) {
+                    //in case the selector bombs we have to retry with a different method
+                }
+            } else {
+                //fallback to the classical filter methods if we cannot use the
+                //html 5 selectors for whatever reason
+                return this._callDelegate("findAll", fragment, filter, deepScan);
+            }
+
+        } finally {
+            //the usual IE6 is broken, fix code
+            filter = null;
+
+        }
+    },
+
+    /**
+     * gets an element from a form with its id -> sometimes two elements have got
+     * the same id but are located in different forms -> MyFaces 1.1.4 two forms ->
+     * 2 inputHidden fields with ID jsf_tree_64 & jsf_state_64 ->
+     * http://www.arcknowledge.com/gmane.comp.jakarta.myfaces.devel/2005-09/msg01269.html
+     *
+     * @param {String} nameId - ID of the HTML element located inside the form
+     * @param {Node} form - form element containing the element
+     * @param {boolean} nameSearch if set to true a search for name is also done
+     * @param {boolean} localOnly if set to true a local search is performed only (a full document search is omitted)
+     * @return {Object}   the element if found else null
+     *
+     * @deprecated this is pointless, per definition only one element with a single id is allowed
+     * in the dom node, multiple names are allowed though but we do not use it that way
+     *
+     */
+    getElementFromForm : function(nameId, form, nameSearch, localOnly) {
+        if (!nameId) {
+            throw Error("_Dom.getElementFromForm an item id or name must be given");
+        }
+
+        if (!form) {
+            return this.byId(nameId);
+        }
+
+        var isNameSearch = !!nameSearch;
+        var isLocalSearchOnly = !!localOnly;
+
+        //we first check for a name entry!
+        if (isNameSearch && this._Lang.exists(form, "elements." + nameId)) {
+            return form.elements[nameId];
+        }
+
+        //if no name entry is found we check for an Id but only in the form
+        var element = this.findById(form, nameId);
+        if (element) {
+            return element;
+        }
+
+        // element not found inside the form -> try document.getElementById
+        // (can be null if element doesn't exist)
+        if (!isLocalSearchOnly) {
+            return this.byId(nameId);
+        }
+
+        return null;
+    },
+
+    /**
+     *
+     * @param {Node} form
+     * @param {String} nameId
+     *
+     * checks for a a element with the name or identifier of nameOrIdentifier
+     * @returns the found node or null otherwise
+     */
+    findFormElement : function(form, nameId) {
+        if (!form) {
+            throw Error("_Dom.findFormElement a form node must be given");
+        }
+        if (!nameId) {
+            throw Error("_Dom.findFormElement an element or identifier must be given");
+        }
+        if (!form.elements) return null;
+        return form.elements[nameId] || this.findById(form, nameId);
+    },
+
+    /**
+     * finds a corresponding html item from a given identifier and
+     * dom fragment
+     * the idea is that the fragment can be detached but yet we still
+     * can search it
+     *
+     * @param fragment the dom fragment to find the item for
+     * @param itemId the identifier of the item
+     */
+    findById : function(fragment, itemId) {
+        //we have to escape here
+
+        if (fragment.getElementById) {
+            return fragment.getElementById(itemId);
+        }
+
+        if (fragment.nodeType == 1 && fragment.querySelector) {
+            try {
+                //we can use the query selector here
+                var newItemId = itemId;
+                if (fragment.id && fragment.id === itemId) return fragment;
+                if (this._Lang.isString(newItemId)) {
+                    newItemId = newItemId.replace(/\./g, "\\.").replace(/:/g, "\\:");
+                }
+
+                return fragment.querySelector("#" + newItemId);
+            } catch(e) {
+                //in case the selector bombs we retry manually
+            }
+        }
+
+        var filter = function(node) {
+            return node && node.id && node.id === itemId;
+        };
+        try {
+            return this.findFirst(fragment, filter);
+        } finally {
+            //ie6 fix code
+            filter = null;
+        }
+    },
+
+
+
+
+
+    /**
+     * findfirst functionality, finds the first element
+     * for which the filter can trigger
+     *
+     * @param fragment the processed fragment/domNode
+     * @param filter a filter closure which either returns true or false depending on triggering or not
+     */
+    findFirst : function(fragment, filter) {
+        this._Lang.assertType(filter, "function");
+
+        if (document.createTreeWalker && NodeFilter) {
+            return this._iteratorFindFirst(fragment, filter);
+        } else {
+            return this._recursionFindFirst(fragment, filter);
+        }
+    },
+
+    /**
+     * a simple recusion based find first which iterates over the
+     * dom tree the classical way which is also the slowest one
+     * but that one will work back to ie6+
+     *
+     * @param fragment the starting fragment
+     * @param filter the filter to be applied to
+     */
+    _recursionFindFirst: function(fragment, filter) {
+        if (filter(fragment)) {
+            return fragment;
+        }
+
+        if (!fragment.childNodes) {
+            return null;
+        }
+
+        //sub-fragment usecases
+        var child;
+        var cnt;
+        var childLen = fragment.childNodes.length;
+        for (cnt = 0; cnt < childLen; cnt++) {
+            child = fragment.childNodes[cnt];
+            var item = this._recursionFindFirst(child, filter);
+            if (item != null)
+                return item;
+        }
+        return null;
+    },
+
+    /**
+     * the faster based iterator findFirst which will work
+     * on all html5 compliant browsers and a bunch of older ones
+     *
+     * @param fragment the fragment to be started from
+     * @param filter the filter which has to be used
+     */
+    _iteratorFindFirst:function(fragment, filter) {
+        if (filter(fragment)) {
+            return fragment;
+        }
+        //we have a tree walker in place this allows for an optimized deep scan
+
+        var walkerFilter = function (node) {
+            return (filter(node)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
+        };
+        var treeWalker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT, walkerFilter, false);
+        if (treeWalker.nextNode()) {
+            /** @namespace treeWalker.currentNode */
+            return treeWalker.currentNode;
+        }
+        return null;
+    }
+
+
+});
\ No newline at end of file

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Mon Aug 16 08:03:56 2010
@@ -61,6 +61,7 @@ myfaces._impl.core._Runtime.singletonExt
 
     _Lang:myfaces._impl._util._Lang,
     _RT:myfaces._impl.core._Runtime,
+    _dummyPlaceHolder: document.createElement("div"),
 
     constructor_: function() {
         //we have to trigger it upfront because mozilla runs the eval
@@ -211,20 +212,14 @@ myfaces._impl.core._Runtime.singletonExt
 
     _outerHTMLCompliant: function(item, markup) {
 
-        var b = this._RT.browser;
-
-        var evalNodes = null;
-        var dummyPlaceHolder = document.createElement("div");
+        var dummyPlaceHolder = this._dummyPlaceHolder; //document.createElement("div");
         dummyPlaceHolder.innerHTML = markup;
-        evalNodes = dummyPlaceHolder.childNodes;
+        var evalNodes = dummyPlaceHolder.childNodes;
+        var evalNodeLen = evalNodes.length;
 
-        if ('undefined' == typeof evalNodes.length) {
-            item.parentNode.replaceChild(evalNodes, item);
-            return evalNodes;
-            //return this.replaceElement(item, evalNodes);
-        } else if (evalNodes.length == 1) {
+        if (evalNodeLen == 1) {
             var ret = evalNodes[0];
-            item.parentNode.replaceChild(evalNodes[0], item);
+            item.parentNode.replaceChild(ret, item);
             return ret;
         } else {
             return this.replaceElements(item, evalNodes);
@@ -248,12 +243,13 @@ myfaces._impl.core._Runtime.singletonExt
      * @param markup
      */
     _outerHTMLNonCompliant: function(item, markup) {
+
         var b = this._RT.browser;
         var evalNodes = null;
         //now to the non w3c compliant browsers
         //http://blogs.perl.org/users/clinton_gormley/2010/02/forcing-ie-to-accept-script-tags-in-innerhtml.html
         //we have to cope with deficiencies between ie and its simulations in this case
-        var probe = document.createElement("div");
+        var probe =  this._dummyPlaceHolder;//document.createElement("div");
         probe.innerHTML = "<table><tbody><tr><td><div></div></td></tr></tbody></table>";
         var depth = 0;
         var newProbe = probe;
@@ -262,10 +258,11 @@ myfaces._impl.core._Runtime.singletonExt
             depth++;
         }
         depth--;
-        this._removeNode(probe, false);
+        this._removeChildNodes(probe, false);
+        probe.innerHTML = "";
 
 
-        var dummyPlaceHolder = document.createElement("div");
+        var dummyPlaceHolder = this._dummyPlaceHolder;//document.createElement("div");
 
         //fortunately a table element also works which is less critical than form elements regarding
         //the inner content
@@ -302,7 +299,8 @@ myfaces._impl.core._Runtime.singletonExt
             //now that Microsoft has finally given
             //ie a working gc in 8 we can skip the costly operation
             if (b.isIE && b.isIE < 8) {
-                this._removeNode(dummyPlaceHolder, false);
+                this._removeChildNodes(dummyPlaceHolder, false);
+                dummyPlaceHolder.innerHTML = "";
             }
         }
     },
@@ -486,117 +484,6 @@ myfaces._impl.core._Runtime.singletonExt
     },
 
     /**
-     * finds a corresponding html item from a given identifier and
-     * dom fragment
-     * @param fragment the dom fragment to find the item for
-     * @param itemId the identifier of the item
-     */
-    findById : function(fragment, itemId) {
-        //we have to escape here
-
-        if (fragment.getElementById) {
-            return fragment.getElementById(itemId);
-        }
-
-        if (fragment.nodeType == 1 && fragment.querySelector) {
-            try {
-                //we can use the query selector here
-                var newItemId = itemId;
-                if (fragment.id && fragment.id === itemId) return fragment;
-                if (this._Lang.isString(newItemId)) {
-                    newItemId = newItemId.replace(/\./g, "\\.").replace(/:/g, "\\:");
-                }
-
-                return fragment.querySelector("#" + newItemId);
-            } catch(e) {
-                //in case the selector bombs we retry manually
-            }
-        }
-
-        var filter = function(node) {
-            return node && node.id && node.id === itemId;
-        };
-        try {
-            return this.findFirst(fragment, filter);
-        } finally {
-            //ie6 fix code
-            filter = null;
-        }
-    },
-
-    /**
-     * findfirst functionality, finds the first element
-     * for which the filter can trigger
-     *
-     * @param fragment the processed fragment/domNode
-     * @param filter a filter closure which either returns true or false depending on triggering or not
-     */
-    findFirst : function(fragment, filter) {
-        this._Lang.assertType(filter, "function");
-
-        if (document.createTreeWalker && NodeFilter) {
-            return this._iteratorFindFirst(fragment, filter);
-        } else {
-            return this._recursionFindFirst(fragment, filter);
-        }
-    },
-
-    /**
-     * a simple recusion based find first which iterates over the
-     * dom tree the classical way which is also the slowest one
-     * but that one will work back to ie6+
-     *
-     * @param fragment the starting fragment
-     * @param filter the filter to be applied to
-     */
-    _recursionFindFirst: function(fragment, filter) {
-        if (filter(fragment)) {
-            return fragment;
-        }
-
-        if (!fragment.childNodes) {
-            return null;
-        }
-
-        //sub-fragment usecases
-        var child;
-        var cnt;
-        var childLen = fragment.childNodes.length;
-        for (cnt = 0; cnt < childLen; cnt++) {
-            child = fragment.childNodes[cnt];
-            var item = this._recursionFindFirst(child, filter);
-            if (item != null)
-                return item;
-        }
-        return null;
-    },
-
-    /**
-     * the faster based iterator findFirst which will work
-     * on all html5 compliant browsers and a bunch of older ones
-     *
-     * @param fragment the fragment to be started from
-     * @param filter the filter which has to be used
-     */
-    _iteratorFindFirst:function(fragment, filter) {
-        if (filter(fragment)) {
-            return fragment;
-        }
-        //we have a tree walker in place this allows for an optimized deep scan
-
-        var walkerFilter = function (node) {
-            return (filter(node)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
-        };
-        var treeWalker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT, walkerFilter, false);
-        if (treeWalker.nextNode()) {
-            /** @namespace treeWalker.currentNode */
-            return treeWalker.currentNode;
-        }
-        return null;
-    },
-
-
-    /**
      * optimized search for an array of tag names
      *
      * @param fragment the fragment which should be searched for
@@ -731,65 +618,7 @@ myfaces._impl.core._Runtime.singletonExt
     }
     ,
 
-    /**
-     * finds the elements by an attached style class
-     *
-     * @param fragment the source fragment which is the root of our search (included in the search)
-     * @param styleClass the styleclass to search for
-     * @param deepScan if set to true a deep scan can be performed
-     */
-    findByStyleClass : function(fragment, styleClass, deepScan) {
-        var filter = this._Lang.hitch(this, function(node) {
-            var classes = this.getClasses(node);
-            var len = classes.length;
-            if (len == 0) return false;
-            else {
-                for (var cnt = 0; cnt < len; cnt++) {
-                    if (classes[cnt] === styleClass) return true;
-                }
-            }
-            return false;
-        });
-        try {
-            deepScan = !!deepScan;
-
-            //html5 getElementsByClassname
-
-            //TODO implement this
-            /*if (fragment.getElementsByClassName && deepScan) {
-             return fragment.getElementsByClassName(styleClass);
-             }
-
-             //html5 speed optimization for browsers which do not ,
-             //have the getElementsByClassName implemented
-             //but only for deep scan and normal parent nodes
-             else */
-            if (this._Lang.exists(fragment, "querySelectorAll") && deepScan) {
-                try {
-                    var result = fragment.querySelectorAll("." + styleClass.replace(/\./g, "\\."));
-
-                    if (fragment.nodeType == 1 && filter(fragment)) {
-                        result = (result == null) ? [] : result;
-                        result = this._Lang.objToArray(result);
-                        result.push(fragment);
-                    }
-                    return result;
-                } catch(e) {
-                    //in case the selector bombs we have to retry with a different method
-                }
-            } else {
-                //fallback to the classical filter methods if we cannot use the
-                //html 5 selectors for whatever reason
-                return this.findAll(fragment, filter, deepScan);
-            }
-
-        } finally {
-            //the usual IE6 is broken, fix code
-            filter = null;
-
-        }
-    }
-    ,
+    
 
     /**
      * a filtered findAll for subdom treewalking
@@ -882,28 +711,7 @@ myfaces._impl.core._Runtime.singletonExt
         //noinspection StatementWithEmptyBodyJS
         while (treeWalker.nextNode());
         return retVal;
-    }
-    ,
-
-    /**
-     *
-     * @param {Node} form
-     * @param {String} nameId
-     *
-     * checks for a a element with the name or identifier of nameOrIdentifier
-     * @returns the found node or null otherwise
-     */
-    findFormElement : function(form, nameId) {
-        if (!form) {
-            throw Error("_Dom.findFormElement a form node must be given");
-        }
-        if (!nameId) {
-            throw Error("_Dom.findFormElement an element or identifier must be given");
-        }
-        if (!form.elements) return null;
-        return form.elements[nameId] || this.findById(form, nameId);
-    }
-    ,
+    },
 
     /**
      * bugfixing for ie6 which does not cope properly with setAttribute
@@ -994,52 +802,7 @@ myfaces._impl.core._Runtime.singletonExt
         }
     },
 
-    /**
-     * gets an element from a form with its id -> sometimes two elements have got
-     * the same id but are located in different forms -> MyFaces 1.1.4 two forms ->
-     * 2 inputHidden fields with ID jsf_tree_64 & jsf_state_64 ->
-     * http://www.arcknowledge.com/gmane.comp.jakarta.myfaces.devel/2005-09/msg01269.html
-     *
-     * @param {String} nameId - ID of the HTML element located inside the form
-     * @param {Node} form - form element containing the element
-     * @param {boolean} nameSearch if set to true a search for name is also done
-     * @param {boolean} localOnly if set to true a local search is performed only (a full document search is omitted)
-     * @return {Object}   the element if found else null
-     *
-     */
-    getElementFromForm : function(nameId, form, nameSearch, localOnly) {
-        if (!nameId) {
-            throw Error("_Dom.getElementFromForm an item id or name must be given");
-        }
-
-        if (!form) {
-            return this.byId(nameId);
-        }
-
-        var isNameSearch = !!nameSearch;
-        var isLocalSearchOnly = !!localOnly;
-
-        //we first check for a name entry!
-        if (isNameSearch && this._Lang.exists(form, "elements." + nameId)) {
-            return form.elements[nameId];
-        }
-
-        //if no name entry is found we check for an Id but only in the form
-        var element = this.findById(form, nameId);
-        if (element) {
-            return element;
-        }
-
-        // element not found inside the form -> try document.getElementById
-        // (can be null if element doesn't exist)
-        if (!isLocalSearchOnly) {
-            return this.byId(nameId);
-        }
-
-        return null;
-    }
-    ,
-
+  
     /**
      * fuzzy form detection which tries to determine the form
      * an item has been detached.
@@ -1160,8 +923,12 @@ myfaces._impl.core._Runtime.singletonExt
             return parentItem && parentItem.tagName
                     && _Lang.equalsIgnoreCase(parentItem.tagName, tagName);
         };
-
-        return this.getFilteredParent(item, searchClosure);
+        try {
+            return this.getFilteredParent(item, searchClosure);
+        } finally {
+            searchClosure = null;
+            _Lang = null;
+        }
     }
     ,
 
@@ -1425,6 +1192,10 @@ myfaces._impl.core._Runtime.singletonExt
 
     byId: function(id) {
         return this._Lang.byId(id);
+    },
+
+    getDummyPlaceHolder: function(markup) {
+        return this._dummyPlaceHolder;
     }
 });
 

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js Mon Aug 16 08:03:56 2010
@@ -192,7 +192,7 @@ myfaces._impl.core._Runtime.singletonDel
             throw Error("myfaces._impl._util._Lang.strToArray param not of type string");
         }
         if (!splitter) {
-            throw Error("myfaces._impl._util._Lang.strToArray a splitter param must be provided which is either a tring or a regexp");
+            throw Error("myfaces._impl._util._Lang.strToArray a splitter param must be provided which is either a string or a regexp");
         }
         var retArr = it.split(splitter);
         var len = retArr.length;
@@ -320,7 +320,7 @@ myfaces._impl.core._Runtime.singletonDel
         var ret = {};
         var keyIdx = {};
         var key = null;
-        var _udef = "undefined";
+        var _undef = "undefined";
         for (key in src) {
             /**
              *we always overwrite dest with source
@@ -333,15 +333,15 @@ myfaces._impl.core._Runtime.singletonDel
                  *on all values being non boolean, we would need an elvis
                  *operator in javascript to shorten this :-(
                  */
-                ret[key] = (_udef != typeof dest[key]) ? dest[key] : src[key];
+                ret[key] = (_undef != typeof dest[key]) ? dest[key] : src[key];
             } else {
-                ret[key] = (_udef != typeof src[key]) ? src[key] : dest[key];
+                ret[key] = (_undef != typeof src[key]) ? src[key] : dest[key];
             }
             keyIdx[key] = true;
         }
         for (key in dest) {
             /*if result.key does not exist we push in dest.key*/
-            ret[key] = (_udef != typeof ret[key]) ? ret[key] : dest[key];
+            ret[key] = (_undef != typeof ret[key]) ? ret[key] : dest[key];
         }
         return ret;
     }
@@ -551,22 +551,23 @@ myfaces._impl.core._Runtime.singletonDel
      * @param argNames the argument names to be transferred
      */
     applyArgs: function(dest, args, argNames) {
+        var _undef = 'undefined';
         if (argNames) {
             for (var cnt = 0; cnt < args.length; cnt++) {
                 //dest can be null or 0 hence no shortcut
-                if ('undefined' != typeof dest["_" + argNames[cnt]]) {
+                if (_undef != typeof dest["_" + argNames[cnt]]) {
                     dest["_" + argNames[cnt]] = args[cnt];
                 }
-                if ('undefined' != typeof dest[ argNames[cnt]]) {
+                if (_undef != typeof dest[ argNames[cnt]]) {
                     dest[argNames[cnt]] = args[cnt];
                 }
             }
         } else {
             for (var key in args) {
-                if ('undefined' != typeof dest["_" + key]) {
+                if (_undef != typeof dest["_" + key]) {
                     dest["_" + key] = args[key];
                 }
-                if ('undefined' != typeof dest[key]) {
+                if (_undef != typeof dest[key]) {
                     dest[key] = args[key];
                 }
             }
@@ -583,15 +584,16 @@ myfaces._impl.core._Runtime.singletonDel
     createErrorMsg: function(sourceClass, func, error) {
         var ret = [];
 
-        ret.push(this.keyValToStr("Affected Class: ", sourceClass));
-        ret.push(this.keyValToStr("Affected Method: ", func));
+        var keyValToStr = this.keyValToStr;
+        ret.push(keyValToStr("Affected Class: ", sourceClass));
+        ret.push(keyValToStr("Affected Method: ", func));
 
         if (error) {
-            ret.push(this.keyValToStr("Error name: ", error.name ? error.name : "undefined"));
-            ret.push(this.keyValToStr("Error message: ", error.message ? error.message : "undefined"));
-            ret.push(this.keyValToStr("Error description: ", error.description ? error.description : "undefined"));
-            ret.push(this.keyValToStr("Error number: ", 'undefined' != typeof error.number ? error.number : "undefined"));
-            ret.push(this.keyValToStr("Error line number: ", 'undefined' != typeof error.lineNumber ? error.lineNumber : "undefined"));
+            ret.push(keyValToStr("Error name: ", error.name ? error.name : "undefined"));
+            ret.push(keyValToStr("Error message: ", error.message ? error.message : "undefined"));
+            ret.push(keyValToStr("Error description: ", error.description ? error.description : "undefined"));
+            ret.push(keyValToStr("Error number: ", 'undefined' != typeof error.number ? error.number : "undefined"));
+            ret.push(keyValToStr("Error line number: ", 'undefined' != typeof error.lineNumber ? error.lineNumber : "undefined"));
         }
         return ret.join("");
     }

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js Mon Aug 16 08:03:56 2010
@@ -95,6 +95,8 @@ myfaces._impl.core._Runtime.extendClass(
 
             // update the amount of space and check whether a shift should occur
             //added here a max limit of 30
+            //now bit shift left is a tad faster than multiplication on most vms and does the same
+            //unless we run into a bit skipping which is impossible in our usecases here
             if ((++this._space) << 1 >= qLen) {
 
                 // set the queue equal to the non-empty portion of the queue

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js Mon Aug 16 08:03:56 2010
@@ -310,6 +310,13 @@ myfaces._impl.core._Runtime.singletonExt
             throw new Error("Transport type " + transportType + " does not exist");
         }
 
+        context._mfInternal = {} ;
+        var mfInternal = context._mfInternal;
+        //additional meta information to speed things up
+        mfInternal["_mfSourceFormId"] = form.id;
+        mfInternal["_mfSourceControlId"] = elementId;
+        mfInternal["_mfTransportType"] = transportType;
+
         this._transport[transportType](elem, form, context, passThrgh);
 
 

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Mon Aug 16 08:03:56 2010
@@ -47,14 +47,14 @@ if (!myfaces._impl.core._Runtime) {
     myfaces._impl.core._Runtime = new function() {
         //the rest of the namespaces can be handled by our namespace feature
         //helper to avoid unneeded hitches
-        var _this = this;
+        var _T = this;
 
         //namespace idx to speed things up by hitting eval way less
-        _this._reservedNMS = {};
+        _T._reservedNMS = {};
         /**
          * global eval on scripts
          *
-         * usage return this.globalEval('myvar.myvar2;');
+         * usage return _T.globalEval('myvar.myvar2;');
          *
          *
          * Note some libraries like jquery use html head attachments
@@ -64,11 +64,11 @@ if (!myfaces._impl.core._Runtime) {
          * we do it via eval, we still can switch to the head method
          * if there are arguments why that one works better than ours
          */
-        this.globalEval = function(code) {
+        _T.globalEval = function(code) {
             //chrome as a diferent global eval, thanks for pointing this out
             //TODO add a config param which allows to evaluate global scripts even if the call
             //is embedded in an iframe
-            if (_this.browser.isIE && window.execScript) {
+            if (_T.browser.isIE && window.execScript) {
                 //execScript definitely only for IE otherwise we might have a custom
                 //window extension with undefined behavior on our necks
                 //window.execScript does not return anything
@@ -104,7 +104,7 @@ if (!myfaces._impl.core._Runtime) {
          * @param nms the namespace to be assigned to
          * @param obj the  object to be assigned
          */
-        this.applyToGlobalNamespace = function(nms, obj) {
+        _T.applyToGlobalNamespace = function(nms, obj) {
             var splitted = nms.split(/\./);
             if (splitted.length == 1) {
                 window[namespace] = obj;
@@ -112,7 +112,7 @@ if (!myfaces._impl.core._Runtime) {
             }
             var parent = splitted.slice(0, splitted.length - 1);
             var child = splitted[splitted.length - 1];
-            var parentNamespace = _this.fetchNamespace(parent.join("."));
+            var parentNamespace = _T.fetchNamespace(parent.join("."));
             parentNamespace[child] = obj;
         };
 
@@ -121,16 +121,16 @@ if (!myfaces._impl.core._Runtime) {
          * @param nms the namespace which has to be fetched
          * @return the object the namespace points to or null if nothing is found
          */
-        this.fetchNamespace = function(nms) {
-            if ('undefined' == typeof nms || null == nms || !_this._reservedNMS[nms]) {
+        _T.fetchNamespace = function(nms) {
+            if ('undefined' == typeof nms || null == nms || !_T._reservedNMS[nms]) {
                 return null;
             }
 
             var ret = null;
             try {
-                if (!this.browser.isIE) {
+                if (!_T.browser.isIE) {
                     //in ie 6 and 7 we get an error entry despite the suppression
-                    ret = _this.globalEval("window." + nms);
+                    ret = _T.globalEval("window." + nms);
                 }
                 //namespace could point to numeric or boolean hence full
                 //save check
@@ -164,7 +164,7 @@ if (!myfaces._impl.core._Runtime) {
          * @param it {|Object|} the object to be checked for being a string
          * @return true in case of being a string false otherwise
          */
-        this.isString = function(/*anything*/ it) {
+        _T.isString = function(/*anything*/ it) {
             //	summary:
             //		Return true if it is a String
             return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
@@ -174,7 +174,7 @@ if (!myfaces._impl.core._Runtime) {
          * reserves a namespace in the specific scope
          *
          * usage:
-         * if(this.reserve("org.apache.myfaces.MyUtils")) {
+         * if(_T.reserve("org.apache.myfaces.MyUtils")) {
          *      org.apache.myfaces.MyUtils = function() {
          *      }
          * }
@@ -184,7 +184,7 @@ if (!myfaces._impl.core._Runtime) {
          *
          *
          * or:
-         * this.reserve("org.apache.myfaces.MyUtils", function() { .. });
+         * _T.reserve("org.apache.myfaces.MyUtils", function() { .. });
          *
          * reserves a namespace and if not already registered directly applies the function the namespace
          *
@@ -198,12 +198,12 @@ if (!myfaces._impl.core._Runtime) {
          * @returns true if it was not provided
          * false otherwise for further action
          */
-        this.reserveNamespace = function(nms, obj) {
+        _T.reserveNamespace = function(nms, obj) {
 
-            if (!_this.isString(nms)) {
+            if (!_T.isString(nms)) {
                 throw Error("Namespace must be a string with . as delimiter");
             }
-            if (_this._reservedNMS[nms] || null != _this.fetchNamespace(nms)) {
+            if (_T._reservedNMS[nms] || null != _T.fetchNamespace(nms)) {
                 return false;
             }
 
@@ -221,7 +221,7 @@ if (!myfaces._impl.core._Runtime) {
                 } else {
                     currNms = currNms[subNamespace];
                 }
-                _this._reservedNMS[tmpNmsName.join(".")] = true;
+                _T._reservedNMS[tmpNmsName.join(".")] = true;
 
             }
 
@@ -232,16 +232,16 @@ if (!myfaces._impl.core._Runtime) {
          * check if an element exists in the root
          * also allows to check for subelements
          * usage
-         * this.exists(rootElem,"my.name.space")
+         * _T.exists(rootElem,"my.name.space")
          * @param {Object} root the root element
          * @param {String} subNms the namespace
          */
-        this.exists = function(root, subNms) {
+        _T.exists = function(root, subNms) {
             if (!root) {
                 return false;
             }
             //special case locally reserved namespace
-            if (root == window && _this._reservedNMS[subNms]) {
+            if (root == window && _T._reservedNMS[subNms]) {
                 return true;
             }
 
@@ -287,7 +287,7 @@ if (!myfaces._impl.core._Runtime) {
          *
          * @return either the config entry or if none is given the default value
          */
-        this.getGlobalConfig = function(configName, defaultValue) {
+        _T.getGlobalConfig = function(configName, defaultValue) {
             /**
              * note we could use exists but this is an heavy operation, since the config name usually
              * given this function here is called very often
@@ -310,7 +310,7 @@ if (!myfaces._impl.core._Runtime) {
          *
          * @return either the config entry or if none is given the default value
          */
-        this.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
+        _T.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
             /*use(myfaces._impl._util)*/
             var _local = !!localOptions;
             var _localResult;
@@ -322,7 +322,7 @@ if (!myfaces._impl.core._Runtime) {
                 _local = 'undefined' != typeof _localResult;
             }
 
-            return (!_local) ? _this.getGlobalConfig(configName, defaultValue) : _localResult;
+            return (!_local) ? _T.getGlobalConfig(configName, defaultValue) : _localResult;
         };
 
         /**
@@ -331,11 +331,11 @@ if (!myfaces._impl.core._Runtime) {
          * 1.5 for mozillas send as binary implementation
          * 2 for xhr level 2
          */
-        this.getXHRLvl = function() {
-            if (!this.XHR_LEVEL) {
-                this.getXHRObject();
+        _T.getXHRLvl = function() {
+            if (!_T.XHR_LEVEL) {
+                _T.getXHRObject();
             }
-            return this.XHR_LEVEL;
+            return _T.XHR_LEVEL;
         }
 
         /**
@@ -347,23 +347,23 @@ if (!myfaces._impl.core._Runtime) {
          *
          * @return the xhr object according to the browser type
          */
-        this.getXHRObject = function() {
+        _T.getXHRObject = function() {
             //since this is a global object ie hates it if we do not check for undefined
             if (window.XMLHttpRequest) {
                 var _ret = new XMLHttpRequest();
                 //we now check the xhr level
                 //sendAsBinary = 1.5 which means mozilla only
                 //upload attribute present == level2
-                if(!this.XHR_LEVEL) {
-                    var _e = this.exists;
-                    this.XHR_LEVEL = (_e(_ret,"sendAsBinary")) ? 1.5 : 1;
-                    this.XHR_LEVEL = (_e(_ret,"upload") && 'undefined' != typeof FormData) ? 2 : this.XHR_LEVEL;
+                if(!_T.XHR_LEVEL) {
+                    var _e = _T.exists;
+                    _T.XHR_LEVEL = (_e(_ret,"sendAsBinary")) ? 1.5 : 1;
+                    _T.XHR_LEVEL = (_e(_ret,"upload") && 'undefined' != typeof FormData) ? 2 : _T.XHR_LEVEL;
                 }
                 return _ret;
             }
             //IE
             try {
-                this.XHR_LEVEL = 1;
+                _T.XHR_LEVEL = 1;
                 return new ActiveXObject("Msxml2.XMLHTTP");
             } catch (e) {
 
@@ -378,8 +378,8 @@ if (!myfaces._impl.core._Runtime) {
          * @param {Boolean} defer  defer true or false, same as the javascript tag defer param
          * @param {String} charSet the charset under which the script has to be loaded
          */
-        this.loadScriptEval = function(src, type, defer, charSet) {
-            var xhr = _this.getXHRObject();
+        _T.loadScriptEval = function(src, type, defer, charSet) {
+            var xhr = _T.getXHRObject();
             xhr.open("GET", src, false);
 
             if (charSet) {
@@ -396,12 +396,12 @@ if (!myfaces._impl.core._Runtime) {
                     //we can achieve that with a small timeout, the timeout
                     //triggers after the processing is done!
                     if (!defer) {
-                        _this.globalEval(xhr.responseText.replace("\n", "\r\n") + "\r\n//@ sourceURL=" + src);
+                        _T.globalEval(xhr.responseText.replace("\n", "\r\n") + "\r\n//@ sourceURL=" + src);
                     } else {
                         //TODO not ideal we maybe ought to move to something else here
                         //but since it is not in use yet, it is ok
                         setTimeout(function() {
-                            _this.globalEval(xhr.responseText + "\r\n//@ sourceURL=" + src);
+                            _T.globalEval(xhr.responseText + "\r\n//@ sourceURL=" + src);
                         }, 1);
                     }
                 } else {
@@ -421,14 +421,14 @@ if (!myfaces._impl.core._Runtime) {
          * @param {Boolean} defer  defer true or false, same as the javascript tag defer param
          * @param {String} charSet the charset under which the script has to be loaded
          */
-        this.loadScriptByBrowser = function(src, type, defer, charSet) {
+        _T.loadScriptByBrowser = function(src, type, defer, charSet) {
             //if a head is already present then it is safer to simply
             //use the body, some browsers prevent head alterations
             //after the first initial rendering
 
             //ok this is nasty we have to do a head modification for ie pre 8
             //the rest can be finely served with body
-            var d = this.browser;
+            var d = _T.browser;
             var position = "head"
             //if(!d.isIE || d.isIE >= 8) {
             //    position = document.getElementsByTagName("body").length ? "body" : "head";
@@ -452,7 +452,7 @@ if (!myfaces._impl.core._Runtime) {
                 }
 
                 //fix for the white page issue
-                // if(this.browser.isIE && this.browser.isIE < 7) {
+                // if(_T.browser.isIE && _T.browser.isIE < 7) {
                 //   holder.insertBefore( script, holder.firstChild );
                 //   holder.removeChild( script );
                 // } else {
@@ -467,16 +467,16 @@ if (!myfaces._impl.core._Runtime) {
             return true;
         };
 
-        this.loadScript = function(src, type, defer, charSet) {
+        _T.loadScript = function(src, type, defer, charSet) {
             //the chrome engine has a nasty javascript bug which prevents
             //a correct order of scripts being loaded
             //if you use script source on the head, we  have to revert
             //to xhr+ globalEval for those
-            if (!_this.browser.isFF) {
-                _this.loadScriptEval(src, type, defer, charSet);
+            if (!_T.browser.isFF) {
+                _T.loadScriptEval(src, type, defer, charSet);
             } else {
                 //only firefox keeps the order, sorry ie...
-                _this.loadScriptByBrowser(src, type, defer, charSet)
+                _T.loadScriptByBrowser(src, type, defer, charSet)
             }
         };
 
@@ -485,25 +485,25 @@ if (!myfaces._impl.core._Runtime) {
         /**
          * delegation pattern
          * usage:
-         * this.delegateObject("my.name.space", delegate,
+         * _T.delegateObject("my.name.space", delegate,
          * {
          *  constructor_ :function(bla, bla1) {
-         *      this._callDelegate("constructor", bla1);
+         *      _T._callDelegate("constructor", bla1);
          *  },
          *  myFunc: function(yyy) {
          *      DoSomething;
-         *      this._callDelegate("someOtherFunc", yyyy);
+         *      _T._callDelegate("someOtherFunc", yyyy);
          *  }, null
          * });
          *
          * or
-         * usage var newClass = this.delegateObject(
+         * usage var newClass = _T.delegateObject(
          * function (var1, var2) {
-         *  this._callDelegate("constructor", var1,var2);
+         *  _T._callDelegate("constructor", var1,var2);
          * };
          * ,delegateObject);
          * newClass.prototype.myMethod = function(arg1) {
-         *      this._callDelegate("myMethod", arg1,"hello world");
+         *      _T._callDelegate("myMethod", arg1,"hello world");
          *
          *
          * @param newCls the new class name to be generated
@@ -511,8 +511,8 @@ if (!myfaces._impl.core._Runtime) {
          * @param protoFuncs the prototype functions which should be attached
          * @param nmsFuncs the namespace functions which should be attached to the namespace
          */
-        this.delegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
-            if (!_this.isString(newCls)) {
+        _T.delegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
+            if (!_T.isString(newCls)) {
                 throw Error("new class namespace must be of type String");
             }
 
@@ -558,13 +558,13 @@ if (!myfaces._impl.core._Runtime) {
          *
          * implements prototype delegaton inheritance dest <- a
          *
-         * usage var newClass = this.extends( function (var1, var2) {
-         *                                          this._callSuper("constructor", var1,var2);
+         * usage var newClass = _T.extends( function (var1, var2) {
+         *                                          _T._callSuper("constructor", var1,var2);
          *                                     };
          *                                  ,origClass);
          *
          *       newClass.prototype.myMethod = function(arg1) {
-         *              this._callSuper("myMethod", arg1,"hello world");
+         *              _T._callSuper("myMethod", arg1,"hello world");
          *       ....
          *
          * other option
@@ -573,7 +573,7 @@ if (!myfaces._impl.core._Runtime) {
          *                              init: function() {constructor...},
          *                              method1: function(f1, f2) {},
          *                              method2: function(f1, f2,f3) {
-         *                                  this._callSuper("method2", F1,"hello world");
+         *                                  _T._callSuper("method2", F1,"hello world");
          *                              }
          *              });
          *
@@ -588,11 +588,11 @@ if (!myfaces._impl.core._Runtime) {
          *  newClass.<namespaceFunction> = function() {...}
          */
 
-        this.extendClass = function(newCls, extendCls, protoFuncs, nmsFuncs) {
-            if (!_this.isString(newCls)) {
+        _T.extendClass = function(newCls, extendCls, protoFuncs, nmsFuncs) {
+            if (!_T.isString(newCls)) {
                 throw Error("new class namespace must be of type String");
             }
-            if (_this._reservedNMS[newCls]) {
+            if (_T._reservedNMS[newCls]) {
                 return;
             }
 
@@ -629,7 +629,6 @@ if (!myfaces._impl.core._Runtime) {
                     var _mappedName = ["_",methodName,"_mf_r"].join("");
                     this._mfClsDescLvl = this._mfClsDescLvl || new Array();
                     var descLevel = this._mfClsDescLvl;
-
                     //we have to detect the descension level
                     //we now check if we are in a super descension for the current method already
                     //if not we are on this level
@@ -668,8 +667,8 @@ if (!myfaces._impl.core._Runtime) {
          * @param {function} extendsCls the function class to be extended
          * @param {Object} protoFuncs (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method
          */
-        this.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) {
-            return _makeSingleton(this.extendClass, newCls, extendsCls, protoFuncs, nmsFuncs);
+        _T.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) {
+            return _makeSingleton(_T.extendClass, newCls, extendsCls, protoFuncs, nmsFuncs);
         };
 
         /**
@@ -680,11 +679,11 @@ if (!myfaces._impl.core._Runtime) {
          * @param protoFuncs the prototype functions which are attached on prototype level
          * @param nmsFuncs the functions which are attached on the classes namespace level
          */
-        this.singletonDelegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
-            if (_this._reservedNMS[newCls]) {
+        _T.singletonDelegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
+            if (_T._reservedNMS[newCls]) {
                 return;
             }
-            return _makeSingleton(this.delegateObj, newCls, delegateObj, protoFuncs, nmsFuncs);
+            return _makeSingleton(_T.delegateObj, newCls, delegateObj, protoFuncs, nmsFuncs);
         };
 
         //since the object is self contained and only
@@ -692,15 +691,15 @@ if (!myfaces._impl.core._Runtime) {
         //functions here, the other parts of the
         //system have to emulate them via _ prefixes
         var _makeSingleton = function(ooFunc, newCls, delegateObj, protoFuncs, nmsFuncs) {
-            if (_this._reservedNMS[newCls]) {
+            if (_T._reservedNMS[newCls]) {
                 return;
             }
 
             var clazz = ooFunc(newCls + "._mfClazz", delegateObj, protoFuncs, nmsFuncs);
             if (clazz != null) {
-                _this.applyToGlobalNamespace(newCls, new clazz());
+                _T.applyToGlobalNamespace(newCls, new clazz());
             }
-            _this.fetchNamespace(newCls)["_mfClazz"] = clazz;
+            _T.fetchNamespace(newCls)["_mfClazz"] = clazz;
         };
 
         //internal class namespace reservation depending on the type (string or function)
@@ -713,10 +712,10 @@ if (!myfaces._impl.core._Runtime) {
                 constr = function() {
                 };
             }
-            if (!_this.reserveNamespace(newCls, constr)) {
+            if (!_T.reserveNamespace(newCls, constr)) {
                 return null;
             }
-            newCls = _this.fetchNamespace(newCls);
+            newCls = _T.fetchNamespace(newCls);
             return newCls;
         };
 
@@ -741,8 +740,8 @@ if (!myfaces._impl.core._Runtime) {
          * @param probe the probe to be checked for the correct type
          * @param theType the type to be checked for
          */
-        this.assertType = function(probe, theType) {
-            return this.isString(theType) ? probe == typeof theType : probe instanceof theType;
+        _T.assertType = function(probe, theType) {
+            return _T.isString(theType) ? probe == typeof theType : probe instanceof theType;
         };
 
         /**
@@ -750,9 +749,9 @@ if (!myfaces._impl.core._Runtime) {
          * @param func the function which should be added to the load
          * chain (note we cannot rely on return values here, hence jsf.util.chain will fail)
          */
-        this.addOnLoad = function(target, func) {
+        _T.addOnLoad = function(target, func) {
             var oldonload = target.onload;
-            target.onload = (!this.assertType(window.onload, "function")) ? func : function() {
+            target.onload = (!_T.assertType(window.onload, "function")) ? func : function() {
                 oldonload();
                 func();
             };
@@ -778,11 +777,11 @@ if (!myfaces._impl.core._Runtime) {
                     dav = n.appVersion,
                     tv = parseFloat(dav);
 
-            _this.browser = {};
-            var d = _this.browser;
+            _T.browser = {};
+            var d = _T.browser;
 
             if (dua.indexOf("Opera") >= 0) {
-                _this.isOpera = tv;
+                _T.isOpera = tv;
             }
             if (dua.indexOf("AdobeAIR") >= 0) {
                 d.isAIR = 1;
@@ -810,7 +809,7 @@ if (!myfaces._impl.core._Runtime) {
                 d.isMozilla = d.isMoz = tv;
             }
             if (d.isMoz) {
-                //We really need to get away from this. Consider a sane isGecko approach for the future.
+                //We really need to get away from _T. Consider a sane isGecko approach for the future.
                 d.isFF = parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1] || dua.split("Shiretoko/")[1]) || undefined;
             }
             if (document.all && !d.isOpera) {

Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js?rev=985823&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js Mon Aug 16 08:03:56 2010
@@ -0,0 +1,160 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * legacy code to enable various aspects
+ * of myfaces, used to be rendered inline
+ * for jsf 2.0 we can externalized it into its own custom resource
+ */
+
+
+
+/**
+ * sets a hidden input field
+ * @param formname the formName
+ * @param name the hidden field
+ * @param value the value to be rendered
+ */
+function oamSetHiddenInput(formname, name, value) {
+    var form = document.forms[formname];
+    if (typeof form == 'undefined') {
+        form = document.getElementById(formname);
+    }
+
+    if (typeof form.elements[name] != 'undefined' && (form.elements[name].nodeName == 'INPUT' || form.elements[name].nodeName == 'input')) {
+        form.elements[name].value = value;
+    }
+    else {
+        var newInput = document.createElement('input');
+        newInput.setAttribute('type', 'hidden');
+        newInput.setAttribute('id', name);
+        newInput.setAttribute('name', name);
+        newInput.setAttribute('value', value);
+        form.appendChild(newInput);
+    }
+}
+
+/**
+ * clears a hidden input field
+ *
+ * @param formname formName for the input
+ * @param name the name of the input field
+ * @param value the value to be cleared
+ */
+function oamClearHiddenInput(formname, name, value) {
+    var form = document.forms[formname];
+
+    if (typeof form == 'undefined') {
+        form = document.getElementById(formname);
+    }
+
+    var hInput = form.elements[name];
+    if (typeof hInput != 'undefined') {
+        form.removeChild(hInput);
+    }
+}
+
+/**
+ * does special form submit remapping
+ * remaps the issuing command link into something
+ * the decode of the command link on the server can understand
+ *
+ * @param formName
+ * @param linkId
+ * @param target
+ * @param params
+ */
+function oamSubmitForm(formName, linkId, target, params) {
+
+    var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
+    if (typeof window[clearFn] == 'function') {
+        window[clearFn](formName);
+    }
+
+    var form = document.forms[formName];
+    if (typeof form == 'undefined') {
+        form = document.getElementById(formName);
+    }
+
+    //autoscroll code
+    if (myfaces.core.config.autoScroll && typeof window.getScrolling != 'undefined') {
+        oamSetHiddenInput(formName, 'autoScroll', getScrolling());
+    }
+
+
+
+
+    if (myfaces.core.config.ieAutoSave) {
+        var agentString = navigator.userAgent.toLowerCase();
+        var version = navigator.appVersion;
+        if (agentString.indexOf('msie') != -1) {
+            if (!(agentString.indexOf('ppc') != -1 && agentString.indexOf('windows ce') != -1 && version >= 4.0)) {
+                window.external.AutoCompleteSaveForm(form);
+            }
+        }
+    }
+
+    var oldTarget = form.target;
+    if (target != null) {
+        form.target = target;
+    }
+    if ((typeof params != 'undefined') && params != null) {
+        for (var i = 0, param; (param = params[i]); i++) {
+            oamSetHiddenInput(formName, param[0], param[1]);
+        }
+
+    }
+
+    oamSetHiddenInput(formName, formName + ':' + '_idcl', linkId);
+
+    if (form.onsubmit) {
+        var result = form.onsubmit();
+        if ((typeof result == 'undefined') || result) {
+            try {
+                form.submit();
+            }
+            catch(e) {
+            }
+        }
+
+    }
+    else {
+        try {
+            form.submit();
+        }
+        catch(e) {
+        }
+    }
+
+    form.target = oldTarget;
+    if ((typeof params != 'undefined') && params != null) {
+
+        for (var i = 0, param; (param = params[i]); i++) {
+            oamClearHiddenInput(formName, param[0], param[1]);
+        }
+
+    }
+
+    oamClearHiddenInput(formName, formName + ':' + '_idcl', linkId);
+    return false;
+}
+
+//reserve a cofig namespace for impl related stuff
+(!window.myfaces) ? window.myfaces = {} : null;
+(!myfaces.core) ? myfaces.core = {} : null;
+(!myfaces.core.config) ? myfaces.core.config = {} : null;
+

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Mon Aug 16 08:03:56 2010
@@ -189,10 +189,12 @@ myfaces._impl.core._Runtime.extendClass(
             //final cleanup to terminate everything
             this._Lang.clearExceptionProcessed();
 
+            //this._context.source;
             if(this._xhr.readyState == this._READY_STATE_DONE) {
                 this._callSuper("_finalize");
             }
 
+
         }
     },
 

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=985823&r1=985822&r2=985823&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Mon Aug 16 08:03:56 2010
@@ -59,7 +59,8 @@ myfaces._impl.core._Runtime.extendClass(
 
         this._Lang = myfaces._impl._util._Lang;
         this._Dom = myfaces._impl._util._Dom;
-
+        this._RT = myfaces._impl.core._Runtime;
+        this._Impl = this._RT.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
     },
     /**
      * uses response to start Html element replacement
@@ -76,7 +77,7 @@ myfaces._impl.core._Runtime.extendClass(
     processResponse : function(request, context) {
 
         try {
-            var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            var _Impl = this._Impl;
 
             // TODO:
             // Solution from
@@ -146,17 +147,25 @@ myfaces._impl.core._Runtime.extendClass(
             }
 
             //fixup missing viewStates due to spec deficiencies
-            this.fixViewStates();
+            this.fixViewStates(context);
         } catch (e) {
             this._onException(request, context, "myfaces._impl.xhrCore._AjaxResponse", "processResponse", e);
         }
     },
 
-    fixViewStates : function() {
+    fixViewStates : function(context) {
 
         if (null == this.appliedViewState) {
             return;
         }
+        //if we set our no portlet env we safely can update all forms with
+        //the new viewstate
+        if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) {
+            for(var cnt = document.forms.length-1; cnt >= 0; cnt --) {
+                 this._setVSTForm(document.forms[cnt]);
+            }
+            return;
+        }
 
         // Now update the forms that were not replaced but forced to be updated, because contains child ajax tags
         // we should only update forms with view state hidden field. If by some reason, the form was set to be
@@ -164,49 +173,50 @@ myfaces._impl.core._Runtime.extendClass(
         // view state is updated.
 
         //set the viewstates of all outer forms parents of our updated elements
-        this._Lang.arrForEach(this._updateForms, this._setVSTOuterForm, 0, this);
+        this._Lang.arrForEach(this._updateForms, this._setVSTForm, 0, this);
 
         //set the viewstate of all forms within our updated elements
         this._Lang.arrForEach(this._updateElems, this._setVSTInnerForms, 0, this);
     },
 
-    _setVSTOuterForm: function(elem) {
-        var viewStateField = this._Dom.findFormElement(elem, this.P_VIEWSTATE);
+    /**
+     * sets the viewstate element in a given form
+     *
+     * @param theForm the form to which the element has to be set to
+     * @param doNotChange if set to true no change is performed if the element is found already to be rendered
+     */
+    _setVSTForm: function(theForm, doNotChange) {
+        var viewStateField = (theForm.elements) ? theForm.elements[this.P_VIEWSTATE] : null;//this._Dom.findFormElement(elem, this.P_VIEWSTATE);
 
-        if (null != viewStateField) {
+        if (viewStateField && !doNotChange) {
             this._Dom.setAttribute(viewStateField, "value", this.appliedViewState);
-        } else {
-            this._appendViewStateElem(elem, this.appliedViewState);
+        } else if (!viewStateField) {
+            var element = this._Dom.getDummyPlaceHolder();
+            element.innerHTML = ["<input type='hidden' name='", this.P_VIEWSTATE ,"' value='" , this.appliedViewState , "' />"].join("");
+            //now we go to proper dom handling after having to deal with another ie screwup
+            try {
+                theForm.appendChild(element.childNodes[0]);
+            } finally {
+                element.innerHTML = "";
+            }
         }
     },
 
-    _appendViewStateElem: function(parent, viewStateVal) {
-        var element = document.createElement("div");
-        element.innerHTML = "<input type='hidden' name='" + this.P_VIEWSTATE + "' value='" + viewStateVal + "' />";
-        //now we go to proper dom handling after having to deal with another ie screwup
-        parent.appendChild(element.childNodes[0]);
-    },
-
     _setVSTInnerForms: function(elem) {
         var replacedForms = this._Dom.findByTagName(elem, "form", false);
-        this._Lang.arrForEach(replacedForms, this._setVSTInnerForm, 0, this);
-    },
+        var applyWithoutChange = this._Lang.hitch(this, function(elem) {
+            this._setVSTForm(elem, true);
+        });
 
-    _setVSTInnerForm: function(elem) {
-        //we first have to fetch the real form element because the fragment
-        //might be detached in some browser implementations
-        var appliedReplacedFrom = document.getElementById(elem.id);
-        var viewStateField = this._Dom.findFormElement(appliedReplacedFrom, this.P_VIEWSTATE);
-
-        //we have to add the viewstate field in case it is not rendered
-        //otherwise those forms cannot issue another submit
-        //if the viewstate field is present we can rely on the viewstate being
-        //at the current state no further updates have to be done
-        if (null == viewStateField) {
-            this._appendViewStateElem(appliedReplacedFrom, this.appliedViewState);
-        }  //else form already has a delivered viewstate field
+        try {
+            this._Lang.arrForEach(replacedForms, applyWithoutChange, 0, this);
+        } finally {
+            applyWithoutChange = false;
+        }
     },
 
+
+
     processError : function(request, context, node) {
         /**
          * <error>
@@ -217,7 +227,7 @@ myfaces._impl.core._Runtime.extendClass(
         var errorName = node.firstChild.textContent || "";
         var errorMessage = node.childNodes[1].firstChild.data || "";
 
-        var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+        var _Impl = this._Impl;
 
         _Impl.sendError(request, context, myfaces._impl.core.Impl.SERVER_ERROR, errorName, errorMessage);
     },
@@ -228,7 +238,7 @@ myfaces._impl.core._Runtime.extendClass(
          */
         var redirectUrl = node.getAttribute("url");
         if (!redirectUrl) {
-            var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            var _Impl = this._Impl;
 
             _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML, myfaces._impl.core.Impl.MALFORMEDXML, "Redirect without url");
             return false;
@@ -277,7 +287,7 @@ myfaces._impl.core._Runtime.extendClass(
                 case this.CMD_EXTENSION:
                     break;
                 default:
-                    var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+                    var _Impl = this._Impl;
                     _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML);
                     return false;
             }
@@ -300,48 +310,19 @@ myfaces._impl.core._Runtime.extendClass(
             // The source form has to be pulled out of the CURRENT document first because the context object
             // may refer to an invalid document if an update of the entire body has occurred before this point.
             var viewStateValue = node.firstChild.nodeValue;
-            var elementId = context.source.id || context.source.name;
-            if ((elementId == null || elementId == '') && context.source.name) {
-                elementId = context.source.name;
-            }
-
-            var sourceForm = this._Dom.fuzzyFormDetection(elementId);
 
-
-            //the source form could be determined absolutely by either the form, the identifier of the node, or the name
-            //if only one element is given
-
-            //fixup we need the current form not the maybe already detached instance
-            //the findParent might refer to a detached instance due to its goParent walking algorithm
-            //so we refer here to the one
-            sourceForm = (sourceForm && 'undefined' != typeof sourceForm.id) ? this._Dom.byId(sourceForm.id) : sourceForm;
-            //now we really have the actual current instance of the form if present
-            /*we check for an element and include a namesearch, but only within the bounds of the committing form*/
-            //we now should have the form, if not the viewstate fixup code at the end of the list
-            //will also be able to recover in almost all instances
+            //TODO save the issuing form id in the context element
+            var elementId = context._mfInternal["_mfSourceControlId"];
+            var sourceForm = document.forms[context._mfInternal["_mfSourceFormId"]] || this._Dom.fuzzyFormDetection(elementId);
             this.appliedViewState = viewStateValue;
+            //source form could not be determined either over the form identifer or the element
+            //we now skip this phase and just add everything we need for the fixup code
 
-            if (null != sourceForm) {
-                var element = null;
-                try {
-                    element = this._Dom.findFormElement(sourceForm, this.P_VIEWSTATE);
-                    this._Dom.setAttribute(element, "value", viewStateValue);
-                } catch (e) {
-                    //in case of an error here we try an early recovery but throw an error to our error handler
-                    this._onException(request, context, "_AjaxResponse", "processUpdate('javax.faces.ViewState')", e);
-                }
-
-                if (!element) {//no element found we have to append a hidden field
-                    this._appendViewStateElem(sourceForm, viewStateValue);
-                }
-                //viewState cannot have split cdata blocks so we can skip the costlier operation
-
+            if (!sourceForm) {
+                return;
             }
-            //note due to a missing spec we have to apply the viewstate as well
-            //to any form which might be rerendered within the render cycle
-            //hence we store the viewstate element for later refererence
-            //to fix up all elements effected by the cycle
 
+            this._setVSTForm(sourceForm);
         }
         else {
             // response may contain several blocks
@@ -371,7 +352,7 @@ myfaces._impl.core._Runtime.extendClass(
                     break;
 
                 default:
-                    var resultNode = this._replaceElement(request, context, node.getAttribute('id'), cDataBlock);
+                    var resultNode = this.replaceHtmlItem(request, context, node.getAttribute('id'), cDataBlock);
                     if (resultNode) {
                         this._pushOperationResult(resultNode);
                     }
@@ -414,7 +395,7 @@ myfaces._impl.core._Runtime.extendClass(
      * @return an xml representation of the page for further processing if possible
      */
     _replaceHead: function(request, context, newData) {
-        var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+        var _Impl = this._Impl;
         var doc = this._Lang.parseXML(newData);
         var newHead = null;
         if (this._Lang.isXMLParseError(doc)) {
@@ -423,7 +404,7 @@ myfaces._impl.core._Runtime.extendClass(
 
         if (this._Lang.isXMLParseError(doc)) {
             //the standard xml parser failed we retry with the stripper
-            var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+            var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
             var headData = parser.parse(newData, "head");
             newHead = this._Lang.parseXML("<root>" + headData + "</root>");
             if (this._Lang.isXMLParseError(newHead)) {
@@ -458,7 +439,7 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {Node} parsedData (optional) preparsed XML representation data of the current document
      */
     _replaceBody : function(request, context, newData /*varargs*/) {
-        var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+        var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
 
         var oldBody = document.getElementsByTagName("body")[0];
         var newBody = document.createElement("body");
@@ -485,7 +466,7 @@ myfaces._impl.core._Runtime.extendClass(
 
         if (this._Lang.isXMLParseError(doc)) {
             //the standard xml parser failed we retry with the stripper
-            var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+            var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
             bodyData = parser.parse(newData, "body");
         } else {
             //parser worked we go on
@@ -499,27 +480,12 @@ myfaces._impl.core._Runtime.extendClass(
         }
 
         bodyParent.replaceChild(newBody, oldBody);
-        var returnedElement = this._replaceElement(request, context, placeHolder, bodyData);
+        var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData);
         if (returnedElement) {
             this._pushOperationResult(returnedElement);
         }
         return returnedElement;
-    }
-    ,
-
-    /**
-     * Helper method to avoid duplicate code
-     * @param {Object} request our request object
-     * @param {Object} context (Map) the response context
-     * @param {Node} oldElement the element to be replaced
-     * @param {String} newData the markup which replaces the old dom node!
-     */
-    _replaceElement : function(request, context, oldElement, newData) {
-        return this.replaceHtmlItem(request, context,
-                oldElement, newData);
-    }
-    ,
-
+    },
 
     /**
      * Replaces HTML elements through others and handle errors if the occur in the replacement part
@@ -528,13 +494,12 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {Object} context (Map)
      * @param {Object} itemIdToReplace (String|Node) - ID of the element to replace
      * @param {String} markup - the new tag
-     * @param {Node} form - form element that is parent of the element
      */
-    replaceHtmlItem : function(request, context, itemIdToReplace, markup, form) {
+    replaceHtmlItem : function(request, context, itemIdToReplace, markup) {
         try {
             // (itemIdToReplace instanceof Node) is NOT compatible with IE8
             var item = (!this._Lang.isString(itemIdToReplace)) ? itemIdToReplace :
-                    this._Dom.getElementFromForm(itemIdToReplace, form);
+                    this._Dom.byId(itemIdToReplace) /*used to call getElementFromForm*/;
             if (!item) {
                 throw Error("myfaces._impl.xhrCore._AjaxResponse.replaceHtmlItem: item with identifier " + itemIdToReplace.toString() + " could not be found");
             }
@@ -559,7 +524,7 @@ myfaces._impl.core._Runtime.extendClass(
     processInsert : function(request, context, node) {
 
         /*remapping global namespaces for speed and readability reasons*/
-        var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+        var _Impl = this._Impl;
 
         var insertId = node.getAttribute('id');
         var beforeId = node.getAttribute('before');
@@ -601,7 +566,7 @@ myfaces._impl.core._Runtime.extendClass(
             parentNode.insertBefore(nodeHolder, beforeNode);
 
             replacementFragment = this.replaceHtmlItem(request, context,
-                    nodeHolder, cDataBlock, null);
+                    nodeHolder, cDataBlock);
 
             if (replacementFragment) {
                 this._pushOperationResult(replacementFragment);
@@ -620,7 +585,7 @@ myfaces._impl.core._Runtime.extendClass(
             parentNode.insertBefore(nodeHolder, afterNode.nextSibling);
 
             replacementFragment = this.replaceHtmlItem(request, context,
-                    nodeHolder, cDataBlock, null);
+                    nodeHolder, cDataBlock);
 
             if (replacementFragment) {
                 this._pushOperationResult(replacementFragment);
@@ -632,7 +597,7 @@ myfaces._impl.core._Runtime.extendClass(
     ,
 
     processDelete : function(request, context, node) {
-        var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+        var _Impl = this._Impl;
 
         var deleteId = node.getAttribute('id');
         if (!deleteId) {
@@ -663,7 +628,7 @@ myfaces._impl.core._Runtime.extendClass(
         //behaves as usual not like the official standard
         //myfaces._impl._util.this._Dom.setAttribute(domNode, attribute, value;
 
-        var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+        var _Impl = this._Impl;
 
         //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
         var elemId = node.getAttribute('id');