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/25 10:37:21 UTC

svn commit: r947959 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_Dom.js _util/_Lang.js _util/_Queue.js core/Impl.js core/_Runtime.js core/jsf-uncompressed.js

Author: werpu
Date: Tue May 25 08:37:20 2010
New Revision: 947959

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


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/core/jsf-uncompressed.js

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=947959&r1=947958&r2=947959&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 Tue May 25 08:37:20 2010
@@ -75,7 +75,7 @@ myfaces._impl.core._Runtime.singletonExt
                     // external script auto eval
                     //TODO fix the encoding here, we have to assume the src is the same encoding as the document
                     //or enforce auto
-                    myfaces._impl.core._Runtime._loadScriptEval(item.getAttribute('src'), item.getAttribute('type'), false, "UTF-8");
+                    myfaces._impl.core._Runtime.loadScriptEval(item.getAttribute('src'), item.getAttribute('type'), false, "UTF-8");
                 } else {
                     // embedded script auto eval
                     var test = item.text;

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=947959&r1=947958&r2=947959&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 Tue May 25 08:37:20 2010
@@ -29,27 +29,32 @@
 //Intellij Warnings settings
 /** @namespace myfaces._impl._util._Lang */
 /** @namespace window.console */
- myfaces._impl.core._Runtime.singletonExtendClass("myfaces._impl._util._Lang", Object, {
+myfaces._impl.core._Runtime.singletonDelegateObj("myfaces._impl._util._Lang", myfaces._impl.core._Runtime, {
+
+
 
     fetchNamespace : function(namespace) {
-        if(!namespace || !this.isString(namespace)) {
+        if (!namespace || !this.isString(namespace)) {
             throw Error("_Lang.fetchNamespace namespace must be of type String");
         }
-        return myfaces._impl.core._Runtime.fetchNamespace(namespace);
+        return this._callDelegate("fetchNamespace",namespace);
     },
 
     reserveNamespace : function(namespace) {
-        if(!this.isString(namespace)) {
+        if (!this.isString(namespace)) {
             throw Error("_Lang.reserveNamespace namespace must be of type String");
         }
-        return myfaces._impl.core._Runtime.reserveNamespace(namespace);
+        return this._callDelegate("reserveNamespace",namespace);
+        //return this._RT.reserveNamespace(namespace);
     },
 
     globalEval : function(code) {
-        if(!this.isString(code)) {
+        if (!this.isString(code)) {
             throw Error("_Lang.globalEval code must be of type String");
         }
-        return myfaces._impl.core._Runtime.globalEval(code);
+        return this._callDelegate("globalEval",code);
+
+        //return this._RT.globalEval(code);
     },
 
     /**
@@ -71,16 +76,16 @@
     /**
      * check if an element exists in the root
      */
-    exists : function(root, subNamespace) {
-        return myfaces._impl.core._Runtime.exists(root, subNamespace);
-    },
+    /*exists : function(root, subNamespace) {
+        return this._RT.exists(root, subNamespace);
+    },*/
 
     /**
-     @see myfaces._impl.core._Runtime.extendClass
+     @see this._RT.extendClass
      */
-    singletonExtendClass : function(newClass, extendsClass, functionMap, inherited) {
-        return myfaces._impl.core._Runtime.singletonExtendClass(newClass, extendsClass, functionMap, inherited);
-    },
+    /*singletonExtendClass : function(newClass, extendsClass, functionMap, inherited) {
+        return this._RT.singletonExtendClass(newClass, extendsClass, functionMap, inherited);
+    },*/
 
 
     /**
@@ -103,11 +108,11 @@
 
 
     /**
-     @see myfaces._impl.core._Runtime.extendClass
+     @see this._RT.extendClass
      */
-    extendClass : function(newClass, extendsClass, functionMap, inherited) {
-        return myfaces._impl.core._Runtime.extendClass(newClass, extendsClass, functionMap, inherited);
-    },
+    /*extendClass : function(newClass, extendsClass, functionMap, inherited) {
+        return this._RT.extendClass(newClass, extendsClass, functionMap, inherited);
+    },*/
 
     //core namespacing and inheritance done, now to the language extensions
 
@@ -188,7 +193,7 @@
             throw Error("myfaces._impl._util._Lang.strToArray a splitter param must be provided which is either a tring or a regexp");
         }
         var retArr = it.split(splitter);
-        var len = retArr.length;
+        //var len = retArr.length;
         for (var cnt = 0; cnt < len; cnt++) {
             retArr[cnt] = this.trim(retArr[cnt]);
         }
@@ -201,7 +206,7 @@
      * crossported from dojo
      */
     trim : function(/*string*/ str) {
-       if(!this.isString(str)) {
+        if (!this.isString(str)) {
             throw Error("_Lang.trim, parameter must be of type String");
         }
         str = str.replace(/^\s\s*/, '');
@@ -303,7 +308,7 @@
      * @param {|boolean|} overwrite if set to true the destination is overwritten if the keys exist in both maps
      **/
     mixMaps : function(dest, src, overwrite) {
-        if(!dest || !src) {
+        if (!dest || !src) {
             throw Error("_Lang.mixMaps, both a source as well as a destination map must be provided");
         }
 
@@ -345,7 +350,7 @@
      * @param {String} str string to check for
      */
     contains : function(arr, str) {
-        if(!arr || !str) {
+        if (!arr || !str) {
             throw Error("_Lang.contains an array and a string must be provided");
         }
 
@@ -369,7 +374,7 @@
      * and functionality wise dirty
      */
     arrToString : function(/*String or array*/ arr, /*string*/ delimiter) {
-        if(!arr) {
+        if (!arr) {
             throw Error("_Lang.arrayToString array must be set");
         }
         if (this.isString(arr)) {
@@ -397,7 +402,7 @@
      */
     addOnLoad: function(func) {
         var oldonload = window.onload;
-        window.onload = (!this.assertType( window.onload, "function")) ? func : function() {
+        window.onload = (!this.assertType(window.onload, "function")) ? func : function() {
             oldonload();
             func();
         };
@@ -432,51 +437,56 @@
      *
      * @param inColl
      */
-    /*  attachIterators : function (inColl ) {
-     var _coll = inColl;
+   /* collection : function (inColl) {
+        var _coll = inColl;
 
-     if(_coll instanceof Array) {
-     if(!_coll.each) {
-     _coll.each = function(closure) {
-     for(var cnt = 0; cnt < _coll.length; cnt++) {
-     closure(_coll[cnt]);
-     }
-     }
-     }
-     if(!_coll.filter) {
-     _coll.filter = function(closure) {
-     var retVal = [];
-     for(var cnt = 0; cnt < _coll.length; cnt++) {
-     var elem = closure(_coll[cnt]);
-     if(closure(elem)) {
-     retVal.push(elem)
-     }
-     }
-     }
-     }
+        if (_coll instanceof Array) {
+            if (!_coll.each) {
+                _coll.each = function(closure) {
+                    for (var cnt = 0; cnt < _coll.length; cnt++) {
+                        //if(caller.this) {
+                        //    closure.apply(caller.this, [cnt, _coll[cnt]]);
+                        //} else {
+                            closure(cnt, _coll[cnt]);
+                        //}
+                    }
+                }
+            }
+            if (!_coll.filter) {
+                _coll.filter = function(closure) {
 
-     } else {
-     if(!_coll.each) {
-     _coll.each = function(closure) {
-     for(var key in _coll.length) {
-     closure(key, _coll[key]);
-     }
-     }
-     }
-     if(!_coll.filter) {
-     _coll.filter = function(closure) {
-     var retVal = [];
-     for(var key in _coll.length) {
-     var elem = closure(_coll[key]);
-     if(closure(key, elem)) {
-     retVal.push(elem)
-     }
-     }
-     }
-     }
+                    var retVal = [];
+                    for (var cnt = 0; cnt < _coll.length; cnt++) {
+                        var elem = closure(_coll[cnt]);
+                        if (closure(cnt, elem)) {
+                            retVal.push(elem)
+                        }
+                    }
+                }
+            }
 
-     }
-     },  */
+        } else {
+            if (!_coll.each) {
+                _coll.each = function(closure) {
+                    for (var key in _coll.length) {
+                        closure(key, _coll[key]);
+                    }
+                }
+            }
+            if (!_coll.filter) {
+                _coll.filter = function(closure) {
+                    var retVal = [];
+                    for (var key in _coll.length) {
+                        var elem = closure(_coll[key]);
+                        if (closure(key, elem)) {
+                            retVal.push(elem)
+                        }
+                    }
+                }
+            }
+
+        }
+    },*/
 
     /**
      * helper to automatically apply a delivered arguments map or array
@@ -546,66 +556,6 @@
         }
         ret.push(delimiter);
         return ret.join("");
-    },
-
-
-    /**
-     * Simple simple logging only triggering at
-     * firebug compatible logging consoles
-     *
-     * note: ;; means the code will be stripped
-     * from the production code by the build system
-     */
-    _log: function(styleClass /*+arguments*/, args) {
-        var logHolder = document.getElementById("myfaces.logging");
-        if (logHolder) {
-            var elem = document.createElement("div");
-            //element.className = styleClass;
-            elem.innerHTML = this.objToArray(arguments, 1).join(" ");
-            logHolder.appendChild(elem);
-        }
-    },
-
-    logLog: function(/*varargs*/) {
-        var argStr = this.objToArray(arguments).join(" ");
-
-        var c = window.console;
-        if (c && c.log) {
-            c.log(argStr);
-        }
-        this._log("logLog", "Log:" + argStr);
-    },
-    logDebug: function(/*varargs*/) {
-        var argStr = this.objToArray(arguments).join(" ");
-        var c = window.console;
-        if (c && c.debug) {
-            c.debug(argStr);
-        }
-        this._log("logDebug", "Debug:" + argStr);
-    },
-    logError: function(/*varargs*/) {
-        var argStr = this.objToArray(arguments).join(" ");
-        var c = window.console;
-        if (c && c.error) {
-            c.error(argStr);
-        }
-        this._log("logError", "Error:" + argStr);
-
-    },
-    logInfo: function(/*varargs*/) {
-        var argStr = this.objToArray(arguments).join(" ");
-        var c = window.console;
-        if (c && c.info) {
-            c.info(argStr);
-        }
-        this._log("logInfo", "Info:" + argStr);
-    },
-    logWarn: function(/*varargs*/) {
-        var argStr = this.objToArray(arguments).join(" ");
-        var c = window.console;
-        if (c && c.warn) {
-            c.warn(argStr);
-        }
-        this._log("logWarn", "Warn:" + argStr);
     }
+   
 });

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=947959&r1=947958&r2=947959&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 Tue May 25 08:37:20 2010
@@ -110,6 +110,12 @@ myfaces._impl.core._Runtime.extendClass(
      * @param closure a closure which processes the element
      */
     each: function(closure) {
+        //we have a browser optimized ecmascript version present
+        //which again is all newer browsers except ie
+        if(Array.prototype.forEach) {
+           return (this._space)? this._q.slice(this._space).forEach( closure ): this._q.forEach( closure ) ;
+        }
+
         var len = this._q.length;
         for (var cnt = this._space; cnt < len; cnt++) {
             closure(this._q[cnt]);
@@ -127,6 +133,13 @@ myfaces._impl.core._Runtime.extendClass(
     filter: function(closure) {
         var ret = [];
         var len = this._q.length;
+
+        //we have a browser optimized ecmascript version present
+        //which again is all newer browsers except ie        
+        if(Array.prototype.filter) {
+           return (this._space)? this._q.slice(this._space).filter( closure ): this._q.filter( closure );
+        }
+        
         for (var cnt = this._space; cnt < len; cnt++) {
             if (closure(this._q[cnt])) {
                 ret.push(this._q[cnt]);

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=947959&r1=947958&r2=947959&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 Tue May 25 08:37:20 2010
@@ -385,6 +385,7 @@ myfaces._impl.core._Runtime.singletonExt
         {
             if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
             {
+                var result = scriptTags[i].src.match(/stage=([^&;]*)/);
                 if (result)
                 {
                     // we found stage=XXX

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=947959&r1=947958&r2=947959&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 Tue May 25 08:37:20 2010
@@ -37,6 +37,10 @@
 (!myfaces._impl.core) ? myfaces._impl.core = {} : null;
 //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
+//Note, this class uses the classical closure approach (to save code)
+//it cannot be inherited by our inheritance mechanism, but must be delegated
+//if you want to derive from it
+//closures and prototype inheritance do not mix, closures and delegation however do
 if (!myfaces._impl.core._Runtime) {
     myfaces._impl.core._Runtime = new function() {
         //the rest of the namespaces can be handled by our namespace feature
@@ -192,106 +196,28 @@ if (!myfaces._impl.core._Runtime) {
             return true;
         };
 
-        this.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);
-
-            _this.browser = {};
-            var d = _this.browser;
-
-            if (dua.indexOf("Opera") >= 0) {
-                _this.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.
-
-                /** @namespace document.documentMode */
-                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
-         */
-        this.getGlobalConfig = function(configName, defaultValue) {
-            /*use(myfaces._impl._util)*/
-
-            if (_this.exists(myfaces, "config") && _this.exists(myfaces.config, configName)) {
-                return myfaces.config[configName];
-            }
-            return defaultValue;
-        };
-
         /**
          * check if an element exists in the root
+         * also allows to check for subelements
+         * usage
+         * this.exists(rootElem,"my.name.space")
+         * @param {Object} root the root element
+         * @param {String} subNms the namespace
          */
-        this.exists = function(root, name) {
+        this.exists = function(root, subNms) {
             if (!root) {
                 return false;
             }
 
             //initial condition root set element not set or null
             //equals to element exists
-            if (!name) {
+            if (!subNms) {
                 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 p = subNms.split(".");
             var len = p.length;
             for (var i = 0; i < len; i++) {
                 //the original dojo code here was false because
@@ -308,6 +234,22 @@ if (!myfaces._impl.core._Runtime) {
         };
 
         /**
+         * 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
+         */
+        this.getGlobalConfig = function(configName, defaultValue) {
+            /*use(myfaces._impl._util)*/
+
+            if (_this.exists(myfaces, "config") && _this.exists(myfaces.config, configName)) {
+                return myfaces.config[configName];
+            }
+            return defaultValue;
+        };
+
+        /**
          * 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
          *
@@ -330,6 +272,8 @@ if (!myfaces._impl.core._Runtime) {
          * (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)
+         *
+         * @return the xhr object according to the browser type
          */
         this.getXHRObject = function() {
             //since this is a global object ie hates it if we do not check for undefined
@@ -345,14 +289,15 @@ if (!myfaces._impl.core._Runtime) {
             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)
+         * @param {String} src  the source of the script
+         * @param {String} type the type of the script
+         * @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) {
+        this.loadScriptEval = function(src, type, defer, charSet) {
             var xhr = _this.getXHRObject();
             xhr.open("GET", src, false);
 
@@ -384,11 +329,20 @@ if (!myfaces._impl.core._Runtime) {
             }
         };
 
-        this._loadScriptByBrowser = function(src, type, defer, charSet) {
+        /**
+         * load script functionality which utilizes the browser internal
+         * script loading capabilities
+         *
+         * @param {String} src  the source of the script
+         * @param {String} type the type of the script
+         * @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) {
             //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
-            var position = document.getElementsByTagName("body").length ? "body" :"head";
+            var position = document.getElementsByTagName("body").length ? "body" : "head";
 
             try {
                 var holder = document.getElementsByTagName(position)[0];
@@ -399,48 +353,102 @@ if (!myfaces._impl.core._Runtime) {
                     html.appendChild(holder);
                 }
                 var script = document.createElement("script");
-                script.type = "text/javascript";
+                script.type = type || "text/javascript";
                 script.src = src;
+                if (charSet) {
+                    script.charset = charSet;
+                }
                 if (defer) {
                     script.defer = defer;
                 }
                 holder.appendChild(script);
             } catch (e) {
-               
-               return false;
+
+                return false;
             }
 
             return true;
         };
 
         this.loadScript = function(src, type, defer, charSet) {
-            if (!_this._loadScriptByBrowser(src, type, defer, charSet)) {
-                _this._loadScriptEval(src, type, defer, charSet);
-            } 
+            if (!_this.loadScriptByBrowser(src, type, defer, charSet)) {
+                _this.loadScriptEval(src, type, defer, charSet);
+            }
         };
 
+        //Base Patterns, Inheritance, Delegation and Singleton
+
+
         /**
-         * Extends a class and puts a singleton instance at the reserved namespace instead
-         * of its original class
+         * delegation pattern
+         * usage:
+         * this.delegateObject("my.name.space", delegate,
+         * {
+         *  constructor_ :function(bla, bla1) {
+         *      this._callDelegate("constructor", bla1);
+         *  },
+         *  myFunc: function(yyy) {
+         *      DoSomething;
+         *      this._callDelegate("someOtherFunc", yyyy);
+         *  }
+         * });
          *
-         * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace
-         * @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
+         * or
+         * usage var newClass = this.delegateObject(
+         * function (var1, var2) {
+         *  this._callDelegate("constructor", var1,var2);
+         * };
+         * ,delegateObject);
+         * newClass.prototype.myMethod = function(arg1) {
+         *      this._callDelegate("myMethod", arg1,"hello world");
+         *
+         *
+         * @param newCls the new class name to be generated
+         * @param delegateObj the delegation object
+         * @param protoFuncs the prototype functions which should be attached
+         * @param nmsFuncs the namespace functions which should be attached to the namespace
          */
-        this.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) {
-
+        this.delegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
             if (!_this.isString(newCls)) {
-                throw Error("New class namespace must be of type string for static initialisation");
-            }
-            //namespace already declared we do not do anything further
-            if (_this.fetchNamespace(newCls)) {
-                return null;
+                throw Error("new class namespace must be of type String");
             }
 
-            var clazz = _this.extendClass(newCls, extendsCls, protoFuncs, nmsFuncs);
-            if (clazz != null) {
-                _this.applyToGlobalNamespace(newCls, new clazz());
+            if ('function' != typeof newCls) {
+                newCls = _reserveClsNms(newCls, protoFuncs);
+                if (!newCls) return null;
             }
+
+            //central delegation mapping core
+            var proto = newCls.prototype;
+
+            //the trick here is to isolate the entries to bind the
+            //keys in a private scope see
+            //http://www.ruzee.com/blog/2008/12/javascript-inheritance-via-prototypes-and-closures
+            for (var key in delegateObj) (function(key, delFn) {
+                //The isolation is needed otherwise the last _key assigend would be picked
+                //up internally
+                if (key && typeof delFn == "function") {
+                    proto[key] = function(/*arguments*/) {
+                        var ret = delFn.apply(delegateObj, arguments);
+                        if ('undefined' != ret) return ret;
+                    };
+                }
+            })(key, delegateObj[key]);
+
+            proto._delegateObj = delegateObj;
+            proto.constructor = newCls;
+
+            proto._callDelegate = function(methodName) {
+                var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1);
+                var ret = this._delegateObj[methodName].apply(this._delegateObj, passThrough);
+                if ('undefined' != ret) return ret;
+            };
+
+            //we now map the function map in
+            _applyFuncs(newCls, protoFuncs, true);
+            _applyFuncs(newCls, nmsFuncs, false);
+
+            return newCls;
         };
 
         /**
@@ -448,21 +456,24 @@ if (!myfaces._impl.core._Runtime) {
          *
          * implements prototype delegaton inheritance dest <- a
          *
-         * usage var newClass = this.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)
-
-         });
+         * usage var newClass = this.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) {
+         *                                  this._callSuper("method2", F1,"hello world");
+         *                              }
+         *              });
          *
          * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace
          * @param {function} extendCls the function class to be extended
@@ -476,54 +487,109 @@ if (!myfaces._impl.core._Runtime) {
          */
 
         this.extendClass = function(newCls, extendCls, protoFuncs, nmsFuncs) {
-            if (!this.isString(newCls)) {
+            if (!_this.isString(newCls)) {
                 throw Error("new class namespace must be of type String");
             }
 
             if ('function' != typeof newCls) {
-
-                var constr = null;
-                if ('undefined' != typeof protoFuncs && null != protoFuncs) {
-                    constr = ('undefined' != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() {
-                    };
-                } else {
-                    constr = function() {
-                    };
-                }
-                if (!_this.reserveNamespace(newCls, constr)) {
-                    return null;
-                }
-                newCls = _this.fetchNamespace(newCls);
+                newCls = _reserveClsNms(newCls, protoFuncs);
+                if (!newCls) return null;
+            }
+            if (extendCls._mfProto) {
+                extendCls = extendCls._mfProto;
             }
 
             if (extendCls) {
                 newCls.prototype = new extendCls;
                 newCls.prototype.constructor = newCls;
-                newCls.prototype.parent = extendCls.prototype;
+                newCls.prototype._parentCls = extendCls.prototype;
 
                 newCls.prototype._callSuper = function(methodName) {
                     var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1);
-                    this.parent[methodName].apply(this, passThrough);
+                    this._parentCls[methodName].apply(this, passThrough);
                 };
             }
 
-            var key;
             //we now map the function map in
-            if (protoFuncs) {
-                for (key in protoFuncs) {
-                    if (key != "_callSuper") {
-                        newCls.prototype[key] = protoFuncs[key];
-                    }
-                }
+            _applyFuncs(newCls, protoFuncs, true);
+            //we could add inherited but that would make debugging harder
+            //see http://www.ruzee.com/blog/2008/12/javascript-inheritance-via-prototypes-and-closures on how to do it
+
+            _applyFuncs(newCls, nmsFuncs, false);
+
+            return newCls;
+        };
+
+
+
+        /**
+         * Extends a class and puts a singleton instance at the reserved namespace instead
+         * of its original class
+         *
+         * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace
+         * @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);
+        };
+
+        /**
+         * delegation pattern which attached singleton generation
+         *
+         * @param newCls the new namespace object to be generated as singletoin
+         * @param delegateObj the object which has to be delegated
+         * @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) {
+            return _makeSingleton(this.delegateObj, newCls, delegateObj, protoFuncs, nmsFuncs);
+        };
+
+        //since the object is self contained and only
+        //can be delegated we can work with real private
+        //functions here, the other parts of the
+        //system have to emulate them via _ prefixes
+        var _makeSingleton = function(ooFunc, newCls, delegateObj, protoFuncs, nmsFuncs) {
+            if (_this.fetchNamespace(newCls)) {
+                return null;
             }
-            if (nmsFuncs) {
-                for (key in nmsFuncs) {
-                    newCls[key] = nmsFuncs[key];
-                }
+            var clazz = ooFunc(newCls + "._mfProto", delegateObj, protoFuncs, nmsFuncs);
+            if (clazz != null) {
+                _this.applyToGlobalNamespace(newCls, new clazz());
+            }
+            _this.fetchNamespace(newCls)["_mfProto"] = clazz;
+        };
+
+        //internal class namespace reservation depending on the type (string or function)
+        var _reserveClsNms = function(newCls, protoFuncs) {
+            var constr = null;
+            if ('undefined' != typeof protoFuncs && null != protoFuncs) {
+                constr = ('undefined' != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() {
+                };
+            } else {
+                constr = function() {
+                };
+            }
+            if (!_this.reserveNamespace(newCls, constr)) {
+                return null;
             }
+            newCls = _this.fetchNamespace(newCls);
             return newCls;
         };
 
+        var _applyFuncs = function (newCls, funcs, proto)
+        {
+            if (funcs) {
+                for (var key in funcs) {
+                    if (!proto)
+                        newCls[key] = funcs[key];
+                    else
+                        newCls.prototype[key] = funcs[key];
+                }
+            }
+        };
+
         /**
          * determines if the embedded scripts have to be evaled manually
          * @return true if a browser combination is given which has to
@@ -553,7 +619,74 @@ if (!myfaces._impl.core._Runtime) {
 
         };
 
-        _this.browserDetection();
-    };
+        //initial browser detection, we encapsule it in a closure
+        //to drop all temporary variables from ram as soon as possible
+        (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);
 
+            _this.browser = {};
+            var d = _this.browser;
+
+            if (dua.indexOf("Opera") >= 0) {
+                _this.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.
+
+                /** @namespace document.documentMode */
+                if (d.isIE >= 8 && document.documentMode != 5) {
+                    d.isIE = document.documentMode;
+                }
+            }
+        })();
+
+    };
 }

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=947959&r1=947958&r2=947959&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Tue May 25 08:37:20 2010
@@ -13,6 +13,8 @@
  *  under the License.
  */
 myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Lang.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_ExtLang.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_UnitTest.js']}", null, null, "UTF-8");
 myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Queue.js']}", null, null, "UTF-8");
 myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_ListenerQueue.js']}", null, null, "UTF-8");
 myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Dom.js']}", null, null, "UTF-8");