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/05/14 12:54:34 UTC

svn commit: r944200 [2/3] - in /myfaces/core/trunk/api/src: assembler/ main/javascript/META-INF/resources/myfaces/_impl/_util/ main/javascript/META-INF/resources/myfaces/_impl/core/ main/javascript/META-INF/resources/myfaces/_impl/xhrCore/ main/javascr...

Added: 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=944200&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Fri May 14 10:54:32 2010
@@ -0,0 +1,568 @@
+/*
+ *  Licensed 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.
+ *  under the License.
+ */
+
+
+/**
+ * Runtime/Startup class
+ * this is the central class which initializes all base mechanisms
+ * used by the rest of the system such as
+ * a) namespacing system
+ * b) browser detection
+ * c) loose configuration coupling
+ * d) utils methods to fetch the implementation
+ * e) ajaxed script loading
+ * f) global eval (because it is used internally)
+ *
+ * Note this class is self contained and must!!! be loaded
+ * as absolute first class before going into anything else
+ *
+ *
+ */
+if ('undefined' == typeof myfaces || myfaces == null) {
+    /**
+     * A simple provide function
+     * fixing the namespaces
+     */
+    /*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*/
+    myfaces = new Object();
+}
+
+if ('undefined' == typeof(myfaces._impl) || null == myfaces._impl) {
+    myfaces._impl = new Object();
+}
+
+if ('undefined' == typeof(myfaces._impl.core) || null == myfaces._impl.core) {
+    myfaces._impl.core = new Object();
+}
+
+//now this is the only time we have to do this cascaded and manually
+//for the rest of the classes our reserveNamespace function will do the trick
+if ('undefined' == typeof  myfaces._impl.core._Runtime || myfaces._impl.core._Runtime == null) {
+    myfaces._impl.core._Runtime = new Object();
+    //the rest of the namespaces can be handled by our namespace feature
+
+    /**
+     * global eval on scripts
+     *
+     * usage return myfaces._impl.core._Runtime.globalEval('myvar.myvar2;');
+     *
+     */
+    myfaces._impl.core._Runtime.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 (myfaces._impl.core._Runtime.browser.isIE && window.execScript) {
+            //execScript definitely only for IE otherwise we might have a custom
+            //window extension with undefined behavior on our necks
+            return window.execScript(code);
+
+        } else if (undefined != typeof (window.eval) && null != window.eval) {
+
+            //fix for a Mozilla bug, Mozilla prevents, that the window is properly applied
+            //the former approach was to scope an outer anonymous function but the scoping is not necessary
+            //Mozilla behaves correctly if you just add an outer function, then the window scope is again
+            //accepted as the real scope
+            var func = function () {
+                return window.eval.call(window, code);
+            };
+            return func();
+        }
+        //we probably have covered all browsers, but this is a safety net which might be triggered
+        //by some foreign browser which is not covered by the above cases
+        return eval.call(window, code);
+    };
+
+    /**
+     * reserves a namespace in the specific scope
+     *
+     * usage:
+     * if(myfaces._impl.core._Runtime.reserve("org.apache.myfaces.MyUtils")) {
+     *      org.apache.myfaces.MyUtils = function() {
+     *      }
+     * }
+     *
+     * reserves a namespace and if the namespace is new the function itself is reserved
+     *
+     *
+     *
+     * or:
+     * myfaces._impl.core._Runtime.reserve("org.apache.myfaces.MyUtils", function() { .. });
+     *
+     * reserves a namespace and if not already registered directly applies the function the namespace
+     *
+     * @param {|String|} nameSpace
+     * @returns true if it was not provided
+     * false otherwise for further action
+     */
+
+    myfaces._impl.core._Runtime.applyToGlobalNamespace = function(nameSpace, obj) {
+        var splittedNamespace = nameSpace.split(/\./);
+        if (splittedNamespace.length == 1) {
+            window[namespace] = obj;
+            return null;
+        }
+        var parent = splittedNamespace.slice(0, splittedNamespace.length - 1);
+        var child = splittedNamespace[splittedNamespace.length - 1];
+        var parentNamespace = myfaces._impl.core._Runtime.fetchNamespace(parent.join("."));
+        parentNamespace[child] = obj;
+    };
+
+    myfaces._impl.core._Runtime.fetchNamespace = function(nameSpace) {
+        try {
+            var origNamespace = nameSpace;
+            nameSpace = myfaces._impl.core._Runtime.globalEval("window." + nameSpace);
+            if ('undefined' == typeof nameSpace || null == nameSpace) {
+                //ie in any version does not like that particularily
+                //we do it the hard way now
+                nameSpace = origNamespace.split(/\./);
+                var currentElem = window;
+                var namespaceLen = nameSpace.length;
+
+                for (var cnt = 0; cnt < namespaceLen; cnt++) {
+                    currentElem = currentElem[nameSpace[cnt]];
+                    if ('undefined' == typeof currentElem || null == currentElem) {
+                        return null;
+                    }
+                }
+                return currentElem;
+            }
+            return nameSpace;
+        } catch (e) {/*wanted*/
+        }
+        return null;
+    };
+
+    /**
+     * Backported from dojo
+     * a failsafe string determination method
+     * (since in javascript String != "" typeof alone fails!)
+     * @param it {|Object|} the object to be checked for being a string
+     * @return true in case of being a string false otherwiseÊ
+     */
+    myfaces._impl.core._Runtime.isString = function(/*anything*/ it) {
+        //	summary:
+        //		Return true if it is a String
+        return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
+    };
+
+    myfaces._impl.core._Runtime.reserveNamespace = function(nameSpace, reservationFunction) {
+        var _Core = myfaces._impl.core._Runtime;
+        if (!_Core.isString(nameSpace)) {
+            throw Error("Namespace must be a string with . as delimiter");
+        }
+        if (null != _Core.fetchNamespace(nameSpace)) {
+            return false;
+        }
+        var namespaceEntries = nameSpace.split(/\./);
+        var currentNamespace = window;
+        for (var cnt = 0; cnt < namespaceEntries.length; cnt++) {
+            var subNamespace = namespaceEntries[cnt];
+            if ('undefined' == typeof currentNamespace[subNamespace]) {
+                currentNamespace[subNamespace] = {};
+            }
+            if (cnt == namespaceEntries.length - 1 && 'undefined' != typeof reservationFunction && null != reservationFunction) {
+                currentNamespace[subNamespace] = reservationFunction;
+            }
+            currentNamespace = currentNamespace[subNamespace];
+        }
+
+        return true;
+    };
+
+    myfaces._impl.core._Runtime.browserDetection = function() {
+        /**
+         * browser detection code
+         * cross ported from dojo 1.2
+         *
+         * dojos browser detection code is very sophisticated
+         * hence we port it over it allows a very fine grained detection of
+         * browsers including the version number
+         * this however only can work out if the user
+         * does not alter the user agent, which they normally dont!
+         *
+         * the exception is the ie detection which relies on specific quirks in ie
+         */
+        var n = navigator;
+        var dua = n.userAgent,
+                dav = n.appVersion,
+                tv = parseFloat(dav);
+
+        myfaces._impl.core._Runtime.browser = {};
+        var d = myfaces._impl.core._Runtime.browser;
+
+        if (dua.indexOf("Opera") >= 0) {
+            myfaces._impl.core._Runtime.isOpera = tv;
+        }
+        if (dua.indexOf("AdobeAIR") >= 0) {
+            d.isAIR = 1;
+        }
+        d.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : 0;
+        d.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined;
+        d.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined;
+
+        // safari detection derived from:
+        //		http://developer.apple.com/internet/safari/faq.html#anchor2
+        //		http://developer.apple.com/internet/safari/uamatrix.html
+        var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);
+        if (index && !d.isChrome) {
+            // try to grab the explicit Safari version first. If we don't get
+            // one, look for less than 419.3 as the indication that we're on something
+            // "Safari 2-ish".
+            d.isSafari = parseFloat(dav.split("Version/")[1]);
+            if (!d.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3) {
+                d.isSafari = 2;
+            }
+        }
+
+        //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
+        if (dua.indexOf("Gecko") >= 0 && !d.isKhtml && !d.isWebKit) {
+            d.isMozilla = d.isMoz = tv;
+        }
+        if (d.isMoz) {
+            //We really need to get away from this. 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) {
+            d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
+            //In cases where the page has an HTTP header or META tag with
+            //X-UA-Compatible, then it is in emulation mode, for a previous
+            //version. Make sure isIE reflects the desired version.
+            //document.documentMode of 5 means quirks mode.
+            if (d.isIE >= 8 && document.documentMode != 5) {
+                d.isIE = document.documentMode;
+            }
+        }
+    };
+
+    /**
+     * fetches a global config entry
+     * @param {String} configName the name of the configuration entry
+     * @param {Object} defaultValue
+     *
+     * @return either the config entry or if none is given the default value
+     */
+    myfaces._impl.core._Runtime.getGlobalConfig = function(configName, defaultValue) {
+        /*use(myfaces._impl._util)*/
+        var _RT = myfaces._impl.core._Runtime;
+
+        if (_RT.exists(myfaces, "config") && _RT.exists(myfaces.config, configName)) {
+            return myfaces.config[configName];
+        }
+        return defaultValue;
+    };
+
+
+
+    /**
+     * check if an element exists in the root
+     */
+    myfaces._impl.core._Runtime.exists = function(root, name) {
+        if('undefined' == typeof root || null == root ) {
+            return false;
+        }
+
+        //initial condition root set element not set or null
+        //equals to element exists
+        if('undefined' == typeof name || null == name) {
+            return true;
+        }
+        //crossported from the dojo toolkit
+        // summary: determine if an object supports a given method
+        // description: useful for longer api chains where you have to test each object in the chain
+        var p = name.split(".");
+        var len =  p.length;
+        for (var i = 0; i < len; i++) {
+            //the original dojo code here was false because
+            //they were testing against ! which bombs out on exists
+            //which has a value set to false
+            // (TODO send in a bugreport to the Dojo people)
+            
+            if ('undefined' == typeof root[p[i]]) {
+                return false;
+            } // Boolean
+            root = root[p[i]];
+        }
+        return true; // Boolean
+    };
+
+    /**
+     * gets the local or global options with local ones having higher priority
+     * if no local or global one was found then the default value is given back
+     *
+     * @param {String} configName the name of the configuration entry
+     * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
+     *
+     * @param {Object} defaultValue the default init value
+     *
+     * @return either the config entry or if none is given the default value
+     */
+    myfaces._impl.core._Runtime.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
+        /*use(myfaces._impl._util)*/
+        var _RT = myfaces._impl._util._Core;
+
+        var globalOption = myfaces._impl._util._Dom.getGlobalConfig(configName, defaultValue);
+        if (!_RT.exists(localOptions, "myfaces") || !_RT.exists(localOptions.myfaces, configName)) {
+            return globalOption;
+        }
+        return localOptions.myfaces[configName];
+    };
+
+    /**
+     * Convenience method
+     * to fetch the implementation from
+     * our lazily binding configuration system
+     */
+    myfaces._impl.core._Runtime.getImpl = function() {
+        myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces.ajax);
+    };
+
+    /**
+     * gets the local or global options with local ones having higher priority
+     * if no local or global one was found then the default value is given back
+     *
+     * @param {String} configName the name of the configuration entry
+     * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
+     *
+     * @param {Object} defaultValue
+     *
+     * @return either the config entry or if none is given the default value
+     */
+    myfaces._impl.core._Runtime.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
+        /*use(myfaces._impl._util)*/
+        var _RT = myfaces._impl.core._Runtime;
+
+        var globalOption = _RT.getGlobalConfig(configName, defaultValue);
+        if (!_RT.exists(localOptions, "myfaces") || !_RT.exists(localOptions.myfaces, configName)) {
+            return globalOption;
+        }
+        return localOptions.myfaces[configName];
+    };
+
+    /**
+     * encapsulated xhr object which tracks down various implementations
+     * of the xhr object in a browser independent fashion
+     * (ie pre 7 used to have non standard implementations because
+     * the xhr object standard came after IE had implemented it first
+     * newer ie versions adhere to the standard and all other new browsers do anyway)
+     */
+    myfaces._impl.core._Runtime.getXHRObject = function() {
+        if ('undefined' != typeof XMLHttpRequest && null != XMLHttpRequest) {
+            return new XMLHttpRequest();
+        }
+        //IE
+        try {
+            return new ActiveXObject("Msxml2.XMLHTTP");
+        } catch (e) {
+
+        }
+        return new ActiveXObject('Microsoft.XMLHTTP');
+    };
+
+    /**
+     * [STATIC]
+     * loads a script and executes it under a global scope
+     * @param {String} src the source to be loaded
+     * @param {String} type the mime type of the script (currently ignored
+     * but in the long run it will be used)
+     */
+    myfaces._impl.core._Runtime.loadScript = function(src, type, defer, charSet) {
+        var xhr = myfaces._impl.core._Runtime.getXHRObject();
+        xhr.open("GET", src, false);
+
+        if ('undefined' != typeof charSet && null != charSet) {
+            xhr.setRequestHeader("Content-Type", "application/x-javascript; charset:" + charSet);
+        }
+
+        xhr.send(null);
+
+        //since we are synchronous we do it after not with onReadyStateChange
+        if (xhr.readyState == 4) {
+            if (xhr.status == 200) {
+                //defer also means we have to process after the ajax response
+                //has been processed
+                //we can achieve that with a small timeout, the timeout
+                //triggers after the processing is done!
+                if (!defer) {
+                    myfaces._impl.core._Runtime.globalEval(xhr.responseText);
+                } else {
+                    setTimeout(function() {
+                        myfaces._impl.core._Runtime.globalEval(xhr.responseText);
+                    }, 1);
+                }
+            } else {
+                throw Error(xhr.responseText);
+            }
+        } else {
+            throw Error("Loading of script " + src + " failed ");
+        }
+    };
+
+    /**
+     * Extends a class and puts a singleton instance at the reserved namespace instead
+     * of its original class
+     *
+     * @param {function|String} newClass either a unnamed function which can be assigned later or a namespace
+     * @param {function} extendsClass the function class to be extended
+     * @param {Object} prototypeFunctions {Map} an optional map of prototype functions which in case of overwriting a base function get an inherited method
+     * @param {Object} prototypeFunctions {Map} an optional map of normal namespace functions which are attached directly to the function of newClass instead of its prototype object
+     */
+    myfaces._impl.core._Runtime.singletonExtendClass = function(newClass, extendsClass, prototypeFunctions, namespaceFunctions) {
+
+        var _Runtime = myfaces._impl.core._Runtime;
+        if (!_Runtime.isString(newClass)) {
+            throw Error("New class namespace must be of type string for static initialisation");
+        }
+        //namespace already declared we do not do anything further
+        if (_Runtime.fetchNamespace(newClass)) {
+            return null;
+        }
+
+        var initializer = myfaces._impl.core._Runtime.extendClass(newClass, extendsClass, prototypeFunctions, namespaceFunctions);
+        if (initializer != null) {
+            _Runtime.applyToGlobalNamespace(newClass, new initializer());
+        }
+    };
+
+    /**
+     * prototype based delegation inheritance
+     *
+     * implements prototype delegaton inheritance dest <- a
+     *
+     * usage var newClass = myfaces._impl.core._Runtime.extends(
+     * function (var1, var2) {
+     *  this.callSuper("constructor", var1,var2);
+     * };
+     * ,origClass);
+     * newClass.prototype.myMethod = function(arg1) {
+     *      this.callSuper("myMethod", arg1,"hello world");
+
+     other option
+     myfaces._impl._core._Runtime.extends("myNamespace.newClass", parent, {
+     init: function() {constructor...},
+     method1: function(f1, f2) {},
+     method2: function(f1, f2,f3)
+
+     });
+     *
+     * @param {function|String} newClass either a unnamed function which can be assigned later or a namespace
+     * @param {function} extendsClass the function class to be extended
+     * @param {Object} prototypeFunctions {Map} an optional map of prototype functions which in case of overwriting a base function get an inherited method
+     * @param {Object} prototypeFunctions {Map} an optional map of normal namespace functions which are attached directly to the function of newClass instead of its prototype object
+     *
+     * To explain further
+     * prototype functions:
+     *  newClass.prototype.<prototypeFunction>
+     * namspace function
+     *  newClass.<namespaceFunction> = function() {...}
+     */
+
+    myfaces._impl.core._Runtime.extendClass = function(newClass, extendsClass, prototypeFunctions) {
+        var _Runtime = myfaces._impl.core._Runtime;
+
+        if ('function' != typeof newClass) {
+
+            var constructor = null;
+            if ('undefined' != typeof prototypeFunctions && null != prototypeFunctions) {
+                constructor = ('undefined' != typeof null != prototypeFunctions['constructor_'] && null != prototypeFunctions['constructor_']) ? prototypeFunctions['constructor_'] : function() {
+                };
+            } else {
+                constructor = function() {
+                };
+            }
+            if (!_Runtime.reserveNamespace(newClass, constructor)) {
+                return null;
+            }
+            newClass = _Runtime.fetchNamespace(newClass);
+        }
+
+        if (null != extendsClass) {
+            newClass.prototype = new extendsClass;
+            newClass.prototype.constructor = newClass;
+            newClass.prototype.parent = extendsClass.prototype;
+
+            newClass.prototype._callSuper = function(methodName) {
+                var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1);
+                this.parent[methodName].apply(this, passThrough);
+            };
+        }
+
+        //we now map the function map in
+        if ('undefined' != typeof prototypeFunctions && null != prototypeFunctions) {
+            for (var key in prototypeFunctions) {
+                newClass.prototype[key] = prototypeFunctions[key];
+                //we also can apply a direct _inherited method if the method overwrites an existing one
+                //http://ejohn.org/blog/simple-javascript-inheritance/ i don not eliminate it multiple calls to super
+                //can happen, this is the way dojo does it
+
+                if (null != extendsClass && 'function' == typeof newClass.prototype.parent[key]) {
+                    //we now aop a decorator function on top of everything,
+                    //to make sure we have super set while it is executing
+                    var assignedFunction = newClass.prototype[key];
+
+                    newClass.prototype[key] = function() {
+                        var oldSuper = newClass.prototype["_inherited"];
+                        newClass.prototype["_inherited"] = function() {
+                            this.parent[key].apply(this, arguments);
+                        };
+                        try {
+                            return assignedFunction.apply(this, arguments);
+                        } finally {
+                            newClass.prototype["_inherited"] = oldSuper;
+                        }
+                    }
+                }
+            }
+        }
+        if ('undefined' != typeof namespaceFunctions && null != namespaceFunctions) {
+            for (var key in namespaceFunctions) {
+                newClass[key] = namespaceFunctions[key];
+            }
+        }
+        return newClass;
+    };
+
+    /**
+     * determines if the embedded scripts have to be evaled manually
+     * @return true if a browser combination is given which has to
+     * do a manual eval
+     * which is currently ie > 5.5, chrome, khtml, webkit safari
+     *
+     */
+    myfaces._impl.core._Runtime.isManualScriptEval = function() {
+        var _RT = myfaces._impl.core._Runtime;
+        var browser = myfaces._impl.core._Runtime.browser;
+        //TODO test this with various browsers so that we have auto eval wherever possible
+        //
+        //tested currently safari, ie, firefox, opera
+        return (_RT.exists(browser, "isIE") &&
+                ( browser.isIE > 5.5)) ||
+                (_RT.exists(browser, "isKhtml") &&
+                        (browser.isKhtml > 0)) ||
+                (_RT.exists(browser, "isWebKit") &&
+                        (browser.isWebKit > 0)) ||
+                (_RT.exists(browser, "isSafari") &&
+                        (browser.isSafari > 0));
+
+        //another way to determine this without direct user agent parsing probably could
+        //be to add an embedded script tag programmatically and check for the script variable
+        //set by the script if existing, the add went through an eval if not then we
+        //have to deal with it ourselves, this might be dangerous in case of the ie however
+        //so in case of ie we have to parse for all other browsers we can make a dynamic
+        //check if the browser does auto eval
+
+    };
+
+    myfaces._impl.core._Runtime.browserDetection();
+}
\ No newline at end of file

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=944200&r1=944199&r2=944200&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 Fri May 14 10:54:32 2010
@@ -13,502 +13,516 @@
  *  under the License.
  */
 
-_reserveMyfacesNamespaces();
+if (myfaces._impl.core._Runtime.reserveNamespace("myfaces._impl.core._jsfImpl")) {
 
-if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.core, "_jsfImpl")) {
-
-    myfaces._impl.core._jsfImpl = function() {
+    myfaces._impl.core._Runtime.applyToGlobalNamespace("myfaces._impl.core._jsfImpl", myfaces._impl.core._Runtime.extendClass(function() {
+    }, Object, {
 
         //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now
-        this._requestHandler = new (myfaces._impl._util._Utils.getGlobalConfig("transport", myfaces._impl.xhrCore._Ajax))();
+        _requestHandler : new (myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Ajax))(),
 
         /**
          * external event listener queue!
          */
-        this._eventListenerQueue = new (myfaces._impl._util._Utils.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))();
+        _eventListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))(),
 
         /**
          * external error listener queue!
          */
-        this._errorListenerQueue = new (myfaces._impl._util._Utils.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))();
+        _errorListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))(),
 
-    };
+        /*CONSTANTS*/
 
-    /*CONSTANTS*/
+        /*internal identifiers for options*/
+        _OPT_IDENT_ALL : "@all",
+        _OPT_IDENT_NONE : "@none",
+        _OPT_IDENT_THIS : "@this",
+        _OPT_IDENT_FORM : "@form",
 
-    /*internal identifiers for options*/
-    myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_ALL = "@all";
-    myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_NONE = "@none";
-    myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_THIS = "@this";
-    myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_FORM = "@form";
-
-    /*
-     * [STATIC] constants
-     */
-
-    myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE = "javax.faces.source";
-    myfaces._impl.core._jsfImpl._PROP_VIEWSTATE = "javax.faces.ViewState";
-    myfaces._impl.core._jsfImpl._PROP_AJAX = "javax.faces.partial.ajax";
-    myfaces._impl.core._jsfImpl._PROP_EXECUTE = "javax.faces.partial.execute";
-    myfaces._impl.core._jsfImpl._PROP_RENDER = "javax.faces.partial.render";
-    myfaces._impl.core._jsfImpl._PROP_EVENT = "javax.faces.partial.event";
-
-    /* message types */
-    myfaces._impl.core._jsfImpl._MSG_TYPE_ERROR = "error";
-    myfaces._impl.core._jsfImpl._MSG_TYPE_EVENT = "event";
-
-    /* event emitting stages */
-    myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN = "begin";
-    myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE = "complete";
-    myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS = "success";
-
-    /*ajax errors spec 14.4.2*/
-    myfaces._impl.core._jsfImpl._ERROR_HTTPERROR = "httpError";
-    myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE = "emptyResponse";
-    myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML = "malformedXML";
-    myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR = "serverError";
-    myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR = "clientError";
-
-    /**
-     * collect and encode data for a given form element (must be of type form)
-     * find the javax.faces.ViewState element and encode its value as well!
-     * return a concatenated string of the encoded values!
-     *
-     * @throws exception in case of the given element not being of type form!
-     * https://issues.apache.org/jira/browse/MYFACES-2110
-     */
-    myfaces._impl.core._jsfImpl.prototype.getViewState = function(formElement) {
-        /**
-         *  typecheck assert!, we opt for strong typing here
-         *  because it makes it easier to detect bugs
+        /*
+         * [STATIC] constants
          */
-        if('undefined' != typeof formElement && null != formElement) {
-            formElement =  myfaces._impl._util._LangUtils.byId(formElement);
-        }
 
-        if ('undefined' == typeof(formElement)
-                || null == formElement
-                || 'undefined' == typeof(formElement.nodeName)
-                || null == formElement.nodeName
-                || formElement.nodeName.toLowerCase() != "form") {
-            throw new Error("jsf.viewState: param value not of type form!");
-        }
-
-        var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
-        return ajaxUtils.processUserEntries(null, null, null,formElement, null);
+        _PROP_PARTIAL_SOURCE : "javax.faces.source",
+        _PROP_VIEWSTATE : "javax.faces.ViewState",
+        _PROP_AJAX : "javax.faces.partial.ajax",
+        _PROP_EXECUTE : "javax.faces.partial.execute",
+        _PROP_RENDER : "javax.faces.partial.render",
+        _PROP_EVENT : "javax.faces.partial.event",
+
+        /* message types */
+        _MSG_TYPE_ERROR : "error",
+        _MSG_TYPE_EVENT : "event",
+
+        /* event emitting stages */
+        _AJAX_STAGE_BEGIN : "begin",
+        _AJAX_STAGE_COMPLETE : "complete",
+        _AJAX_STAGE_SUCCESS : "success",
+
+        /*ajax errors spec 14.4.2*/
+        _ERROR_HTTPERROR : "httpError",
+        _ERROR_EMPTY_RESPONSE : "emptyResponse",
+        _ERROR_MALFORMEDXML : "malformedXML",
+        _ERROR_SERVER_ERROR : "serverError",
+        _ERROR_CLIENT_ERROR : "clientError",
 
-    };
 
-    /**
-     * internal assertion check for the element parameter
-     * it cannot be null or undefined
-     * it must be either a string or a valid existing dom node
-     */
-    myfaces._impl.core._jsfImpl.prototype._assertElement = function(/*String|Dom Node*/ element) {
-        /*namespace remap for our local function context we mix the entire function namespace into
-         *a local function variable so that we do not have to write the entire namespace
-         *all the time
-         **/
-        var JSF2Utils = myfaces._impl._util._LangUtils;
 
         /**
-         * assert element
-         */
-        if ('undefined' == typeof( element ) || null == element) {
-            throw new Error("jsf.ajax, element must be set!");
-        }
-        //        if (!JSF2Utils.isString(element) && !(element instanceof Node)) {
-        //            throw new Error("jsf.ajax, element either must be a string or a dom node");
-        //        }
-
-        element = JSF2Utils.byId(element);
-        if ('undefined' == typeof element || null == element) {
-            throw new Error("Element either must be a string to a or must be a valid dom node");
-        }
+         * collect and encode data for a given form element (must be of type form)
+         * find the javax.faces.ViewState element and encode its value as well!
+         * return a concatenated string of the encoded values!
+         *
+         * @throws error in case of the given element not being of type form!
+         * https://issues.apache.org/jira/browse/MYFACES-2110
+         */
+        getViewState : function(formElement) {
+            /**
+             *  typecheck assert!, we opt for strong typing here
+             *  because it makes it easier to detect bugs
+             */
+            if ('undefined' != typeof formElement && null != formElement) {
+                formElement = myfaces._impl._util._Lang.byId(formElement);
+            }
 
-    };
+            if ('undefined' == typeof(formElement)
+                    || null == formElement
+                    || 'undefined' == typeof(formElement.nodeName)
+                    || null == formElement.nodeName
+                    || formElement.nodeName.toLowerCase() != "form") {
+                throw new Error("jsf.viewState: param value not of type form!");
+            }
 
-    myfaces._impl.core._jsfImpl.prototype._assertFunction = function(func) {
-        if ('undefined' == typeof func || null == func) {
-            return;
-        }
-        if (!(func instanceof Function)) {
-            throw new Error("Functioncall " + func + " is not a function! ");
-        }
-    };
+            var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
+            return ajaxUtils.processUserEntries(null, null, null, formElement, null);
+
+        },
 
-    /**
-     * this function has to send the ajax requests
-     *
-     * following request conditions must be met:
-     * <ul>
-     *  <li> the request must be sent asynchronously! </li>
-     *  <li> the request must be a POST!!! request </li>
-     *  <li> the request url must be the form action attribute </li>
-     *  <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
-     * </ul>
-     *
-     * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted
-     * @param {|Event|} event: any javascript event supported by that object
-     * @param {|Map|} options : map of options being pushed into the ajax cycle
-     */
-    myfaces._impl.core._jsfImpl.prototype.request = function(element, event, options) {
-
-        /*namespace remap for our local function context we mix the entire function namespace into
-         *a local function variable so that we do not have to write the entire namespace
-         *all the time
-         **/
-        var JSF2Utils = myfaces._impl._util._LangUtils;
-        var elementId = null;
         /**
-         * we cross reference statically hence the mapping here
-         * the entire mapping between the functions is stateless
-         */
-        element = JSF2Utils.byId(element);
-        if ('undefined' != typeof element && null != element) {
-            //detached element handling, we also store the element name
-            //to get a fallback option in case the identifier is not determinable
-            // anymore, in case of a framework induced detachment the element.name should
-            // be shared if the identifier is not determinable anymore
-            elementId = ('undefined' != typeof element.id)? element.id: null;
-            if((elementId == null || elementId == '') && 'undefined' != typeof element.name) {
-                elementId = element.name;
+         * internal assertion check for the element parameter
+         * it cannot be null or undefined
+         * it must be either a string or a valid existing dom node
+         */
+        _assertElement : function(/*String|Dom Node*/ element) {
+            /*namespace remap for our local function context we mix the entire function namespace into
+             *a local function variable so that we do not have to write the entire namespace
+             *all the time
+             **/
+            var _Lang = myfaces._impl._util._Lang;
+
+            /**
+             * assert element
+             */
+            if ('undefined' == typeof( element ) || null == element) {
+                throw new Error("jsf.ajax, element must be set!");
+            }
+            //        if (!JSF2Utils.isString(element) && !(element instanceof Node)) {
+            //            throw new Error("jsf.ajax, element either must be a string or a dom node");
+            //        }
+
+            element = _Lang.byId(element);
+            if ('undefined' == typeof element || null == element) {
+                throw new Error("Element either must be a string to a or must be a valid dom node");
             }
-        }
 
-        /*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*/
-        this._assertFunction(options.onevent);
+        },
 
-        /*
-         * We make a copy of our options because
-         * we should not touch the incoming params!
-         */
-        var passThroughArguments = JSF2Utils.mixMaps({}, options, true);
+        _assertFunction : function(func) {
+            if ('undefined' == typeof func || null == func) {
+                return;
+            }
+            if (!(func instanceof Function)) {
+                throw new Error("Functioncall " + func + " is not a function! ");
+            }
+        },
 
-        /*additional passthrough cleanup*/
-        /*ie6 supportive code to prevent browser leaks*/
-        passThroughArguments.onevent = null;
-        delete passThroughArguments.onevent;
-        /*ie6 supportive code to prevent browser leaks*/
-        passThroughArguments.onerror = null;
-        delete passThroughArguments.onerror;
+        /**
+         * this function has to send the ajax requests
+         *
+         * following request conditions must be met:
+         * <ul>
+         *  <li> the request must be sent asynchronously! </li>
+         *  <li> the request must be a POST!!! request </li>
+         *  <li> the request url must be the form action attribute </li>
+         *  <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
+         * </ul>
+         *
+         * @param {String|Node} element any dom element no matter being it html or jsf, from which the event is emitted
+         * @param {|Event|} event any javascript event supported by that object
+         * @param {|Object|} options  map of options being pushed into the ajax cycle
+         */
+        request : function(element, event, options) {
+
+            /*namespace remap for our local function context we mix the entire function namespace into
+             *a local function variable so that we do not have to write the entire namespace
+             *all the time
+             **/
+            var _Lang = myfaces._impl._util._Lang;
+            var elementId = null;
+            /**
+             * we cross reference statically hence the mapping here
+             * the entire mapping between the functions is stateless
+             */
+            element = _Lang.byId(element);
+            event = ('undefined' == typeof event && window.event) ? window.event : event;
+
+            if ('undefined' != typeof element && null != element) {
+                //detached element handling, we also store the element name
+                //to get a fallback option in case the identifier is not determinable
+                // anymore, in case of a framework induced detachment the element.name should
+                // be shared if the identifier is not determinable anymore
+                elementId = ('undefined' != typeof element.id) ? element.id : null;
+                if ((elementId == null || elementId == '') && 'undefined' != typeof element.name) {
+                    elementId = element.name;
+                }
+            }
 
-        if ('undefined' != typeof event && null != event) {
-            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EVENT] = event.type;
-        }
+            /*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*/
+            this._assertFunction(options.onevent);
+
+            /*
+             * We make a copy of our options because
+             * we should not touch the incoming params!
+             */
+            var passThroughArguments = _Lang.mixMaps({}, options, true);
+
+            /*additional passthrough cleanup*/
+            /*ie6 supportive code to prevent browser leaks*/
+            passThroughArguments.onevent = null;
+            delete passThroughArguments.onevent;
+            /*ie6 supportive code to prevent browser leaks*/
+            passThroughArguments.onerror = null;
+            delete passThroughArguments.onerror;
 
-        /**
-         * ajax pass through context with the source
-         * onevent and onerror
-         */
-        var ajaxContext = {};
-        ajaxContext.source = element;
-        ajaxContext.onevent = options.onevent;
-        ajaxContext.onerror = options.onerror;
+            if ('undefined' != typeof event && null != event) {
+                passThroughArguments[this._PROP_EVENT] = event.type;
+            }
 
-        /**
-         * fetch the parent form
-         */
+            /**
+             * ajax pass through context with the source
+             * onevent and onerror
+             */
+            var ajaxContext = {};
+            ajaxContext.source = element;
+            ajaxContext.onevent = options.onevent;
+            ajaxContext.onerror = options.onerror;
+
+            /**
+             * fetch the parent form
+             */
 
-        var sourceForm = myfaces._impl._util._Utils.fuzzyFormDetection(null, ajaxContext, element);
-        if (null == sourceForm) {
-            throw Error("Sourcform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
-        }
 
-        /**
-         * binding contract the javax.faces.source must be set
-         */
-        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE] = elementId;
 
-        /**
-         * javax.faces.partial.ajax must be set to true
-         */
-        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_AJAX] = true;
+            var sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(element);
+            var _Lang = myfaces._impl._util._Lang;
+            if (null == sourceForm && 'undefined' != typeof event && null != event) {
+                sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(_Lang.getEventTarget(event));
+                if(null == sourceForm) {
+                    throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
+                }    
+            }  else if(null == sourceForm) {
+                throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
+            }
 
-        /**
-         * if execute or render exist
-         * we have to pass them down as a blank delimited string representation
-         * of an array of ids!
-         */
-        if (JSF2Utils.exists(passThroughArguments, "execute")) {
-            /*the options must be a blank delimited list of strings*/
-            var execString = JSF2Utils.arrayToString(passThroughArguments.execute, ' ');
-            var execNone = execString.indexOf(this._OPT_IDENT_NONE) != -1;
-            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, elementId);
-
-                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = execString;
-            } else if (execAll) {
-                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = this._OPT_IDENT_ALL;
-            }
-
-            passThroughArguments.execute = null;
-            /*remap just in case we have a valid pointer to an existing object*/
-            delete passThroughArguments.execute;
-        } else {
-            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = elementId;
-        }
+            /**
+             * binding contract the javax.faces.source must be set
+             */
+            passThroughArguments[this._PROP_PARTIAL_SOURCE] = elementId;
+
+            /**
+             * javax.faces.partial.ajax must be set to true
+             */
+            passThroughArguments[this._PROP_AJAX] = true;
+
+            /**
+             * if execute or render exist
+             * we have to pass them down as a blank delimited string representation
+             * of an array of ids!
+             */
+            if (_Lang.exists(passThroughArguments, "execute")) {
+                /*the options must be a blank delimited list of strings*/
+                var execString = _Lang.arrayToString(passThroughArguments.execute, ' ');
+                var execNone = execString.indexOf(this._OPT_IDENT_NONE) != -1;
+                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, elementId);
+
+                    passThroughArguments[this._PROP_EXECUTE] = execString;
+                } else if (execAll) {
+                    passThroughArguments[this._PROP_EXECUTE] = this._OPT_IDENT_ALL;
+                }
+
+                passThroughArguments.execute = null;
+                /*remap just in case we have a valid pointer to an existing object*/
+                delete passThroughArguments.execute;
+            } else {
+                passThroughArguments[this._PROP_EXECUTE] = elementId;
+            }
 
-        if (JSF2Utils.exists(passThroughArguments, "render")) {
-            var renderString = JSF2Utils.arrayToString(passThroughArguments.render, ' ');
-            var renderNone = renderString.indexOf(this._OPT_IDENT_NONE) != -1;
-            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, elementId);
-                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_RENDER] = renderString;
-                passThroughArguments.render = null;
-            } else if (renderAll) {
-                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_RENDER] = this._OPT_IDENT_ALL;
+            if (_Lang.exists(passThroughArguments, "render")) {
+                var renderString = _Lang.arrayToString(passThroughArguments.render, ' ');
+                var renderNone = renderString.indexOf(this._OPT_IDENT_NONE) != -1;
+                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, elementId);
+                    passThroughArguments[this._PROP_RENDER] = renderString;
+                    passThroughArguments.render = null;
+                } else if (renderAll) {
+                    passThroughArguments[this._PROP_RENDER] = this._OPT_IDENT_ALL;
 
+                }
+                delete passThroughArguments.render;
             }
-            delete passThroughArguments.render;
-        }
 
-        //implementation specific options are added to the context for further processing
-        if ('undefined' != typeof passThroughArguments.myfaces && null != passThroughArguments.myfaces) {
-            ajaxContext.myfaces = passThroughArguments.myfaces;
-            delete passThroughArguments.myfaces;
-        }
+            //implementation specific options are added to the context for further processing
+            if ('undefined' != typeof passThroughArguments.myfaces && null != passThroughArguments.myfaces) {
+                ajaxContext.myfaces = passThroughArguments.myfaces;
+                delete passThroughArguments.myfaces;
+            }
 
-        this._requestHandler._ajaxRequest(element, sourceForm, ajaxContext, passThroughArguments);
+            this._requestHandler._ajaxRequest(element, sourceForm, ajaxContext, passThroughArguments);
 
-    };
+        },
 
-    myfaces._impl.core._jsfImpl.prototype.addOnError = function(/*function*/errorListener) {
-        /*error handling already done in the assert of the queue*/
-        this._errorListenerQueue.add(errorListener);
-    };
-
-    myfaces._impl.core._jsfImpl.prototype.addOnEvent = function(/*function*/eventListener) {
-        /*error handling already done in the assert of the queue*/
-        this._eventListenerQueue.add(eventListener);
-    };
-
-    /**
-     * implementation triggering the error chain
-     *
-     * @param {Object} request the request object which comes from the xhr cycle
-     * @param {Map} context the context object being pushed over the xhr cycle keeping additional metadata
-     * @param {String} name, the error name
-     * @param {String} serverErrorName the server error name in case of a server error
-     * @param {String} serverErrorMessage the server error message in case of a server error
-     *
-     *  handles the errors, in case of an onError exists within the context the onError is called as local error handler
-     *  the registered error handlers in the queue receiv an error message to be dealt with
-     *  and if the projectStage is at development an alert box is displayed
-     *
-     *  note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided
-     *  which changes the default output behavior from alert to something else
-     *
-     *
-     */
-    myfaces._impl.core._jsfImpl.prototype.sendError = function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage) {
-        var eventData = {};
-        eventData.type = myfaces._impl.core._jsfImpl._MSG_TYPE_ERROR;
-
-        eventData.status = name;
-        eventData.serverErrorName = serverErrorName;
-        eventData.serverErrorMessage = serverErrorMessage;
+        addOnError : function(/*function*/errorListener) {
+            /*error handling already done in the assert of the queue*/
+            this._errorListenerQueue.add(errorListener);
+        },
+
+        addOnEvent : function(/*function*/eventListener) {
+            /*error handling already done in the assert of the queue*/
+            this._eventListenerQueue.add(eventListener);
+        },
 
-        try {
-            eventData.source = context.source;
-            eventData.responseXML = request.responseXML;
-            eventData.responseText = request.responseText;
-            eventData.responseCode = request.status;
-        } catch (e) {
-            // silently ignore: user can find out by examining the event data
-        }
+        /**
+         * implementation triggering the error chain
+         *
+         * @param {Object} request the request object which comes from the xhr cycle
+         * @param {Object} context (Map) the context object being pushed over the xhr cycle keeping additional metadata
+         * @param {String} name the error name
+         * @param {String} serverErrorName the server error name in case of a server error
+         * @param {String} serverErrorMessage the server error message in case of a server error
+         *
+         *  handles the errors, in case of an onError exists within the context the onError is called as local error handler
+         *  the registered error handlers in the queue receiv an error message to be dealt with
+         *  and if the projectStage is at development an alert box is displayed
+         *
+         *  note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided
+         *  which changes the default output behavior from alert to something else
+         *
+         *
+         */
+        sendError : function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage) {
+            var eventData = {};
+            //we keep this in a closure because we might reuse it for our serverErrorMessage
+            var malFormedMessage = function() {
+                return ('undefined' != typeof name && name == myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML) ? "The server response could not be parsed, the server has returned with a response which is not xml !" :"";
+            };
+
+            eventData.type = this._MSG_TYPE_ERROR;
+
+            eventData.status = name;
+            eventData.serverErrorName = serverErrorName;
+            eventData.serverErrorMessage = serverErrorMessage;
 
-        /**/
-        if (myfaces._impl._util._LangUtils.exists(context, "onerror")) {
-            context.onerror(eventData);
-        }
+            try {
+                eventData.source = context.source;
+                eventData.responseCode = request.status;
+                eventData.responseText = request.responseText;
+                eventData.responseXML = request.responseXML;
+            } catch (e) {
+                // silently ignore: user can find out by examining the event data
+            }
 
-        /*now we serve the queue as well*/
-        this._errorListenerQueue.broadcastEvent(eventData);
+            /**/
+            if (myfaces._impl._util._Lang.exists(context, "onerror")) {
+                context.onerror(eventData);
+            }
 
-        if (jsf.getProjectStage() === "Development") {
-            var defaultErrorOutput = myfaces._impl._util._Utils.getGlobalConfig("defaultErrorOutput", alert);
-            var finalMessage = [];
-
-            finalMessage.push(('undefined' != typeof name && null != name) ? name : "");
-            finalMessage.push(('undefined' != typeof serverErrorName && null != serverErrorName) ? serverErrorName : "");
-            finalMessage.push(('undefined' != typeof serverErrorMessage && null != serverErrorMessage) ? serverErrorMessage : "");
+            /*now we serve the queue as well*/
+            this._errorListenerQueue.broadcastEvent(eventData);
 
-            defaultErrorOutput(finalMessage.join("-"));
-        }
-    };
+            if (jsf.getProjectStage() === "Development" && this._errorListenerQueue.length() == 0) {
+                var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert);
+                var finalMessage = [];
+
+                finalMessage.push(('undefined' != typeof name && null != name) ? name : "");
+                finalMessage.push(('undefined' != typeof serverErrorName && null != serverErrorName) ? serverErrorName : "");
+                finalMessage.push(('undefined' != typeof serverErrorMessage && null != serverErrorMessage) ? serverErrorMessage : "");
+                finalMessage.push(malFormedMessage());
 
-    /**
-     * sends an event
-     */
-    myfaces._impl.core._jsfImpl.prototype.sendEvent = function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
-        var eventData = {};
-        eventData.type = myfaces._impl.core._jsfImpl._MSG_TYPE_EVENT;
+                defaultErrorOutput(finalMessage.join("-") + " Note, this message is only sent, because project stage is development and no " +
+                        "other error listeners are registered.");
+            }
+        },
 
-        eventData.status = name;
-        eventData.source = context.source;
+        /**
+         * sends an event
+         */
+        sendEvent : function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
+            var eventData = {};
+            eventData.type = this._MSG_TYPE_EVENT;
 
-        if (name !== myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN) {
+            eventData.status = name;
+            eventData.source = context.source;
+
+            if (name !== this._AJAX_STAGE_BEGIN) {
+
+                try {
+                    eventData.responseCode = request.status;
+                    eventData.responseText = request.responseText;
+                    eventData.responseXML = request.responseXML;
+                    
+                } catch (e) {
+                    var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces.ajax);
+                    impl.sendError(request, context, this._ERROR_CLIENT_ERROR, "ErrorRetrievingResponse",
+                            "Parts of the response couldn't be retrieved when constructing the event data: " + e);
+                    //client errors are not swallowed
+                    throw e;
+                }
 
-            try {
-                eventData.responseXML = request.responseXML;
-                eventData.responseText = request.responseText;
-                eventData.responseCode = request.status;
-            } catch (e) {
-                var impl = myfaces._impl._util._Utils.getGlobalConfig("jsfAjaxImpl", myfaces.ajax);
-                impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, "ErrorRetrievingResponse",
-                        "Parts of the response couldn't be retrieved when constructing the event data: " + e);
-                //client errors are not swallowed 
-                throw e;
             }
 
-        }
+            /**/
+            if (myfaces._impl._util._Lang.exists(context, "onevent")) {
+                /*calling null to preserve the original scope*/
+                context.onevent.call(null, eventData);
+            }
 
-        /**/
-        if (myfaces._impl._util._LangUtils.exists(context, "onevent")) {
-            /*calling null to preserve the original scope*/
-            context.onevent.call(null, eventData);
-        }
+            /*now we serve the queue as well*/
+            this._eventListenerQueue.broadcastEvent(eventData);
+        },
+
+        /**
+         * processes the ajax response if the ajax request completes successfully
+         * @param {Object} request (xhrRequest) the ajax request!
+         * @param {Object} context (Map) context map keeping context data not being passed down over
+         * the request boundary but kept on the client
+         */
+        response : function(request, context) {
+            this._requestHandler._ajaxResponse(request, context);
+        },
 
-        /*now we serve the queue as well*/
-        this._eventListenerQueue.broadcastEvent(eventData);
-    };
-
-    /**
-     * processes the ajax response if the ajax request completes successfully
-     * @param {xhrRequest} request the ajax request!
-     * @param {Map} context, context map keeping context data not being passed down over
-     * the request boundary but kept on the client
-     */
-    myfaces._impl.core._jsfImpl.prototype.response = function(request, context) {
-        this._requestHandler._ajaxResponse(request, context);
-    };
-
-    /**
-     * @return the project stage also emitted by the server:
-     * it cannot be cached and must be delivered over the server
-     * The value for it comes from the request parameter of the jsf.js script called "stage".
-     */
-    myfaces._impl.core._jsfImpl.prototype.getProjectStage = function() {
-        /* run through all script tags and try to find the one that includes jsf.js */
-        var scriptTags = document.getElementsByTagName("script");
-        for (var i = 0; i < scriptTags.length; i++)
-        {
-            if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
+        /**
+         * @return the project stage also emitted by the server:
+         * it cannot be cached and must be delivered over the server
+         * The value for it comes from the request parameter of the jsf.js script called "stage".
+         */
+        getProjectStage : function() {
+            /* run through all script tags and try to find the one that includes jsf.js */
+            var scriptTags = document.getElementsByTagName("script");
+            for (var i = 0; i < scriptTags.length; i++)
             {
-                /* try to extract stage=XXX */
-                var result = scriptTags[i].src.match(/stage=([^&;]*)/);
-                if (result)
+                if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
                 {
-                    /* we found stage=XXX */
-                    /* return only valid values of ProjectStage */
-                    if (result[1] == "Production"
-                            || result[1] == "Development"
-                            || result[1] == "SystemTest"
-                            || result[1] == "UnitTest")
+                    /* try to extract stage=XXX */
+                    var result = scriptTags[i].src.match(/stage=([^&;]*)/);
+                    if (result)
+                    {
+                        /* we found stage=XXX */
+                        /* return only valid values of ProjectStage */
+                        if (result[1] == "Production"
+                                || result[1] == "Development"
+                                || result[1] == "SystemTest"
+                                || result[1] == "UnitTest")
+                        {
+                            return result[1];
+                        }
+                    }
+                    else
                     {
-                        return result[1];
+                        /* we found the script, but there was no stage parameter --> Production */
+                        return "Production";
                     }
                 }
-                else
-                {
-                    /* we found the script, but there was no stage parameter --> Production */
-                    return "Production";
+            }
+            /* we could not find anything valid --> return the default value */
+            return "Production";
+        },
+
+        /**
+         * implementation of the external chain function
+         * moved into the impl
+         *
+         *  @param {Object} source the source which also becomes
+         * the scope for the calling function (unspecified side behavior)
+         * the spec states here that the source can be any arbitrary code block.
+         * Which means it either is a javascript function directly passed or a code block
+         * which has to be evaluated separately.
+         *
+         * After revisiting the code additional testing against components showed that
+         * the this parameter is only targeted at the component triggering the eval
+         * (event) if a string code block is passed. This is behavior we have to resemble
+         * in our function here as well, I guess.
+         *
+         * @param {Event} event the event object being passed down into the the chain as event origin
+         *   the spec is contradicting here, it on one hand defines event, and on the other
+         *   it says it is optional, after asking, it meant that event must be passed down
+         *   but can be undefined
+         */
+        chain : function(source, event) {
+            var len = arguments.length;
+            //the spec is contradicting here, it on one hand defines event, and on the other
+            //it says it is optional, I have cleared this up now
+            //the spec meant the param must be passed down, but can be 'undefined'
+            if (len < 2) {
+                throw new Error(" an event object or unknown must be passed as second parameter ");
+            } else if (len < 3) {
+                if ('function' == typeof event || myfaces._impl._util._Lang.isString(event)) {
+                    throw new Error(" an event must be passed down (either a an event object null or undefined) ");
                 }
+                //nothing to be done here, move along
+                return true;
             }
-        }
-        /* we could not find anything valid --> return the default value */
-        return "Production";
-    };
-
-    /**
-     * implementation of the external chain function
-     * moved into the impl
-     *
-     *  @param {Object} source the source which also becomes
-     * the scope for the calling function (unspecified side behavior)
-     * the spec states here that the source can be any arbitrary code block.
-     * Which means it either is a javascript function directly passed or a code block
-     * which has to be evaluated separately.
-     *
-     * After revisiting the code additional testing against components showed that
-     * the this parameter is only targeted at the component triggering the eval
-     * (event) if a string code block is passed. This is behavior we have to resemble
-     * in our function here as well, I guess.
-     *
-     * @param {Event} event the event object being passed down into the the chain as event origin
-     *   the spec is contradicting here, it on one hand defines event, and on the other
-     *   it says it is optional, after asking, it meant that event must be passed down
-     *   but can be undefined
-     */
-    myfaces._impl.core._jsfImpl.prototype.chain = function(source, event) {
-        var len = arguments.length;
-        //the spec is contradicting here, it on one hand defines event, and on the other
-        //it says it is optional, I have cleared this up now
-        //the spec meant the param must be passed down, but can be 'undefined'
-        if (len < 2) {
-            throw new Error(" an event object or unknown must be passed as second parameter ");    
-        } else if (len < 3) {
-            if ('function' == typeof event || myfaces._impl._util._LangUtils.isString(event)) {
-                throw new Error(" an event must be passed down (either a an event object null or undefined) ");
+            //now we fetch from what is given from the parameter list
+            //we cannot work with splice here in any performant way so we do it the hard way
+            //arguments only are give if not set to undefined even null values!
+
+            //assertions source either null or set as dom element:
+
+            if ('undefined' == typeof source) {
+                throw new Error(" source must be defined");
+                //allowed chain datatypes
+            } else if ('function' == typeof source) {
+                throw new Error(" source cannot be a function (probably source and event were not defined or set to null");
+            }
+            if (myfaces._impl._util._Lang.isString(source)) {
+                throw new Error(" source cannot be a string ");
             }
-            //nothing to be done here, move along
-            return true;
-        }
-        //now we fetch from what is given from the parameter list
-        //we cannot work with splice here in any performant way so we do it the hard way
-        //arguments only are give if not set to undefined even null values!
-
-        //assertions source either null or set as dom element:
-
-        if ('undefined' == typeof source) {
-            throw new Error(" source must be defined");
-            //allowed chain datatypes
-        } else if ('function' == typeof source) {
-            throw new Error(" source cannot be a function (probably source and event were not defined or set to null");
-        }
-        if (myfaces._impl._util._LangUtils.isString(source)) {
-            throw new Error(" source cannot be a string ");
-        }
-
-        var thisVal = source;
 
-        //assertion if event is a function or a string we already are in our function elements
-        //since event either is undefined, null or a valid event object
-        
-        if ('function' == typeof event || myfaces._impl._util._LangUtils.isString(event)) {
-            throw new Error(" an event must be passed down (either a an event object null or undefined) ");
-        }
+            //assertion if event is a function or a string we already are in our function elements
+            //since event either is undefined, null or a valid event object
 
+            if ('function' == typeof event || myfaces._impl._util._Lang.isString(event)) {
+                throw new Error(" an event must be passed down (either a an event object null or undefined) ");
+            }
 
-        for (var loop = 2; loop < len; loop++) {
-            //we do not change the scope of the incoming functions
-            //but we reuse the argument array capabilities of apply
-            var retVal;
+            for (var loop = 2; loop < len; loop++) {
+                //we do not change the scope of the incoming functions
+                //but we reuse the argument array capabilities of apply
+                var retVal;
+
+                if ('function' == typeof arguments[loop]) {
+                    retVal = arguments[loop].call(source, event);
+                } else {
+                    //either a function or a string can be passed in case of a string we have to wrap it into another function
+                    retVal = new Function("event", arguments[loop]).call(source, event);
+                }
+                //now if one function returns false in between we stop the execution of the cycle
+                //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering
+                if ('undefined' != typeof retVal && retVal === false) {
+                    return false;
+                }
 
-            if ('function' == typeof arguments[loop]) {
-                 retVal = arguments[loop].call(thisVal, event);
-            } else {
-                //either a function or a string can be passed in case of a string we have to wrap it into another function
-                 retVal = new Function("event", arguments[loop]).call(thisVal, event);
-            }
-            //now if one function returns false in between we stop the execution of the cycle
-            //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering
-            if ('undefined' != typeof retVal && retVal === false) {
-                return false;
             }
+            return true;
 
         }
-        return true;
-
-    };
-
+    }));
     // singleton
     myfaces.ajax = new myfaces._impl.core._jsfImpl();
 }

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=944200&r1=944199&r2=944200&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 Fri May 14 10:54:32 2010
@@ -1,165 +1,165 @@
-/*
- * Copyright 2009 Ganesh Jung
- * 
- * Licensed 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.
- *
- * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
- *
- */
-
-_reserveMyfacesNamespaces();
-
-if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.xhrCore, "_AjaxRequest")) {
-
-    /**
-     * Constructor
-     * @param {HtmlElement} source - Item that triggered the request
-     * @param {Html Form} sourceForm - Form containing source
-     * @param {Map} context - AJAX context
-     * @param {Map} passThrough - parameters to pass through to the server (execute/render)
-     */
-    myfaces._impl.xhrCore._AjaxRequest = function(source, sourceForm, context, passThrough) {
-        this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
-        try {
-            this.m_contentType = "application/x-www-form-urlencoded";
-            this.m_source = source;
-            this.m_xhr = null;
-            // myfaces parameters
-            this.m_partialIdsArray = null;
-            var errorlevel = 'NONE';
-            this.m_queuesize = -1;
-
-            /*namespace remapping for readability*/
-            var _Utils = myfaces._impl._util._Utils;
-            var _LangUtils = myfaces._impl._util._LangUtils;
-
-            if (_Utils.getLocalOrGlobalConfig(context,"errorlevel", null) != null) {
-                errorlevel = context.myfaces.errorlevel;
-            }
-            if (_Utils.getLocalOrGlobalConfig(context,"queuesize", null) != null) {
-                this.m_queuesize = context.myfaces.queuesize;
-            }
-            if (_Utils.getLocalOrGlobalConfig(context,"pps", null) != null
-                &&  _LangUtils.exists(passThrough,myfaces._impl.core._jsfImpl._PROP_EXECUTE)
-                && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
-                this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
-            }
-            if (_Utils.getLocalOrGlobalConfig(context,"timeout", null) != null) {
-            	this.m_timeout = context.myfaces.timeout;
-            }
-            if (_Utils.getLocalOrGlobalConfig(context,"delay", null) != null) {
-            	this.m_delay = context.myfaces.delay;
-            }
-            this.m_context = context;
-            this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
-            this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
-            this.m_sourceForm = sourceForm;
-            this.m_passThrough = passThrough;
-            this.m_requestParameters = this.getViewState();
-            for (var key in this.m_passThrough) {
-                this.m_requestParameters = this.m_requestParameters +
-                "&" + encodeURIComponent(key) +
-                "=" + encodeURIComponent(this.m_passThrough[key]);
-            }
-        } catch (e) {
-            this.m_exception.throwError(null, context, "Ctor", e);
-        }
-    };
-
-    /**
-     * Sends an Ajax request
-     */
-    myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
-        try {
-            var ajaxRequestQueue =  myfaces._impl.xhrCore._AjaxRequestQueue.queue;
-
-            this.m_xhr = myfaces._impl._util._Utils.getXHRObject();
-            
-            this.m_xhr.open("POST", this.m_sourceForm.action, true);
-            this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
-            this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
-            this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
-
-            myfaces.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
-            this.m_xhr.send(this.m_requestParameters);
-            if ('undefined' != typeof this.m_timeout) {
-	            var timeoutId = window.setTimeout(
-	            	function() {
-	            		try {
-		            		if ( ajaxRequestQueue.m_request.m_xhr.readyState > 0
-		            		&& ajaxRequestQueue.queue.m_request.m_xhr.readyState < 4) {
-		            			ajaxRequestQueue.queue.m_request.m_xhr.abort();
-		            		}
-	            		} catch (e) {
-	            			// don't care about exceptions here
-	            		}
-	            	}, this.m_timeout);
-            }
-        } catch (e) {
-            this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
-           
-        }
-    };
-
-    /**
-     * Callback method to process the Ajax response
-     * triggered by RequestQueue
-     */
-    myfaces._impl.xhrCore._AjaxRequest.prototype.requestCallback = function() {
-        var READY_STATE_DONE = 4;
-        try {
-            //local namespace remapping
-            var jsfAjaxImpl = myfaces.ajax;
-
-            if (this.m_xhr.readyState == READY_STATE_DONE) {
-                if (this.m_xhr.status >= 200 && this.m_xhr.status < 300) {
-                	jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
-                	jsfAjaxImpl.response(this.m_xhr, this.m_context);
-                	jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS);
-                    myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
-                } else {
-                	jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
-            		var errorText;
-                	try {
-                		errorText = "Request failed";
-                		if (this.m_xhr.status) {
-                			errorText += "with status " + this.m_xhr.status;
-                			if (this.m_xhr.statusText) {
-                				errorText += " and reason " + this.m_xhr.statusText;
-                			}
-                		}
-                	} catch (e) {
-                		errorText = "Request failed with unknown status";
-                	}
-                	jsfAjaxImpl.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._ERROR_HTTPERROR,
-                        myfaces._impl.core._jsfImpl._ERROR_HTTPERROR, errorText);
-                }
-            }
-        } catch (e) {
-            this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
-        }
-    }
-
-    /**
-     * Spec. 13.3.1
-     * Collect and encode input elements.
-     * Additionally the hidden element javax.faces.ViewState
-     * @return {String} - Concatenated String of the encoded input elements
-     * 			and javax.faces.ViewState element
-     */
-    myfaces._impl.xhrCore._AjaxRequest.prototype.getViewState = function() {
-        return this.m_ajaxUtil.processUserEntries(this.m_xhr, this.m_context, this.m_source,
-            this.m_sourceForm, this.m_partialIdsArray);
-    }
-}
+/*
+ * Copyright 2009 Ganesh Jung
+ * 
+ * Licensed 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.
+ *
+ * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
+ * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
+ *
+ */
+
+/**
+ * Constructor
+ * @param {Node} source - Item that triggered the request
+ * @param {Node} sourceForm (form) - Form containing source
+ * @param {Object} context (Map) - AJAX context
+ * @param {Object} passThrough (Map) - parameters to pass through to the server (execute/render)
+ */
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", Object, {
+
+    constructor_: function(source, sourceForm, context, passThrough) {
+        this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
+        try {
+            this.m_contentType = "application/x-www-form-urlencoded";
+            this.m_source = source;
+            this.m_xhr = null;
+            // myfaces parameters
+            this.m_partialIdsArray = null;
+            var errorlevel = 'NONE';
+            this.m_queuesize = -1;
+
+            /*namespace remapping for readability*/
+            var _Runtime = myfaces._impl.core._Runtime;
+            var _Lang = myfaces._impl._util._Lang;
+
+            if (_Runtime.getLocalOrGlobalConfig(context, "errorlevel", null) != null) {
+                errorlevel = context.myfaces.errorlevel;
+            }
+            if (_Runtime.getLocalOrGlobalConfig(context, "queuesize", null) != null) {
+                this.m_queuesize = context.myfaces.queuesize;
+            }
+            if (_Runtime.getLocalOrGlobalConfig(context, "pps", null) != null
+                    && _Lang.exists(passThrough, myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE)
+                    && passThrough[myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE].length > 0) {
+                this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE].split(" ");
+            }
+            if (_Runtime.getLocalOrGlobalConfig(context, "timeout", null) != null) {
+                this.m_timeout = context.myfaces.timeout;
+            }
+            if (_Runtime.getLocalOrGlobalConfig(context, "delay", null) != null) {
+                this.m_delay = context.myfaces.delay;
+            }
+            this.m_context = context;
+            this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
+            this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
+            this.m_sourceForm = sourceForm;
+            this.m_passThrough = passThrough;
+            this.m_requestParameters = this.getViewState();
+            for (var key in this.m_passThrough) {
+                this.m_requestParameters = this.m_requestParameters +
+                        "&" + encodeURIComponent(key) +
+                        "=" + encodeURIComponent(this.m_passThrough[key]);
+            }
+        } catch (e) {
+            this.m_exception.throwError(null, context, "Ctor", e);
+        }
+    },
+
+    /**
+     * Sends an Ajax request
+     */
+    send : function() {
+        try {
+            var ajaxRequestQueue = myfaces._impl.xhrCore._AjaxRequestQueue.queue;
+
+            this.m_xhr = myfaces._impl.core._Runtime.getXHRObject();
+
+            this.m_xhr.open("POST", this.m_sourceForm.action, true);
+            this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
+            this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
+            this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
+
+            myfaces.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_BEGIN);
+            this.m_xhr.send(this.m_requestParameters);
+            if ('undefined' != typeof this.m_timeout) {
+                var timeoutId = window.setTimeout(
+                        function() {
+                            try {
+                                if (ajaxRequestQueue.m_request.m_xhr.readyState > 0
+                                        && ajaxRequestQueue.queue.m_request.m_xhr.readyState < 4) {
+                                    ajaxRequestQueue.queue.m_request.m_xhr.abort();
+                                }
+                            } catch (e) {
+                                // don't care about exceptions here
+                            }
+                        }, this.m_timeout);
+            }
+        } catch (e) {
+            this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
+
+        }
+    },
+
+    /**
+     * Callback method to process the Ajax response
+     * triggered by RequestQueue
+     */
+    requestCallback : function() {
+        var READY_STATE_DONE = 4;
+        try {
+            //local namespace remapping
+            var jsfAjaxImpl = myfaces.ajax;
+
+            if (this.m_xhr.readyState == READY_STATE_DONE) {
+                if (this.m_xhr.status >= 200 && this.m_xhr.status < 300) {
+                    jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_COMPLETE);
+                    jsfAjaxImpl.response(this.m_xhr, this.m_context);
+                    jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_SUCCESS);
+                    myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
+                } else {
+                    jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_COMPLETE);
+                    var errorText;
+                    try {
+                        errorText = "Request failed";
+                        if (this.m_xhr.status) {
+                            errorText += "with status " + this.m_xhr.status;
+                            if (this.m_xhr.statusText) {
+                                errorText += " and reason " + this.m_xhr.statusText;
+                            }
+                        }
+                    } catch (e) {
+                        errorText = "Request failed with unknown status";
+                    }
+                    jsfAjaxImpl.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._ERROR_HTTPERROR,
+                            myfaces._impl.core._jsfImpl.prototype._ERROR_HTTPERROR, errorText);
+                }
+            }
+        } catch (e) {
+            this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
+        }
+    },
+
+    /**
+     * Spec. 13.3.1
+     * Collect and encode input elements.
+     * Additionally the hidden element javax.faces.ViewState
+     * @return {String} - Concatenated String of the encoded input elements
+     *             and javax.faces.ViewState element
+     */
+    getViewState : function() {
+        return this.m_ajaxUtil.processUserEntries(this.m_xhr, this.m_context, this.m_source,
+                this.m_sourceForm, this.m_partialIdsArray);
+    }
+
+});
+

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js?rev=944200&r1=944199&r2=944200&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js Fri May 14 10:54:32 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2009 Ganesh Jung
- * 
+ *
  * Licensed 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.
@@ -17,10 +17,8 @@
  * Version: $Revision: 1.3 $ $Date: 2009/05/31 09:16:44 $
  *
  */
-
-_reserveMyfacesNamespaces();
-
-if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.xhrCore, "_AjaxRequestQueue")) {
+if (myfaces._impl.core._Runtime.reserveNamespace("myfaces._impl.xhrCore._AjaxRequestQueue")) {
+    //TODO this class needs namespace cleanups
 
     /**
      * Constructor
@@ -76,7 +74,7 @@ if (!myfaces._impl._util._LangUtils.exis
 			// already timed out
 		}
     }
-    
+
     /**
      * send a request or keep it in a queue
      * @param {myfaces._impl.xhrCore._AjaxRequest} request - request to send