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 2011/11/16 16:18:54 UTC

svn commit: r1202738 - in /myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl: core/Impl.js core/Object.js core/_Runtime.js xhrCore/engine/Xhr1.js

Author: werpu
Date: Wed Nov 16 15:18:53 2011
New Revision: 1202738

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


Modified:
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=1202738&r1=1202737&r2=1202738&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js Wed Nov 16 15:18:53 2011
@@ -21,11 +21,7 @@
  * @description Implementation singleton which implements all interface method
  * defined by our jsf.js API
  * */
-_MF_SINGLTN(_PFX_CORE+"Impl", _MF_OBJECT,
-/**
- * @lends myfaces._impl.core.Impl.prototype
- */
-{
+_MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /**  @lends myfaces._impl.core.Impl.prototype */ {
 
     //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now
     _transport      : myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Transports),

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js?rev=1202738&r1=1202737&r2=1202738&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js Wed Nov 16 15:18:53 2011
@@ -38,6 +38,8 @@ _MF_CLS(_PFX_CORE+"Object", Object, {
     /*optional functionality can be provided
      * for ie6 but is turned off by default*/
     _initDefaultFinalizableFields: function() {
+        var isIE = this._RT.browser.isIE;
+        if(!isIE || isIE > 7) return;
         for (var key in this) {
             //per default we reset everything which is not preinitalized
             if (null == this[key] && key != "_resettableContent" && key.indexOf("_mf") != 0 && key.indexOf("_") == 0) {

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=1202738&r1=1202737&r2=1202738&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Wed Nov 16 15:18:53 2011
@@ -544,7 +544,7 @@ if (!myfaces._impl.core._Runtime) {
             var className = newCls;
 
             if (_T._reservedNMS[newCls]) {
-                return;
+                return _T.fetchNamespace(newCls);
             }
             var constr = "constructor_";
             var parClassRef = "_mfClazz";
@@ -580,6 +580,9 @@ if (!myfaces._impl.core._Runtime) {
                 var clzProto = newClazz.prototype;
                 clzProto.constructor = newCls;
                 clzProto._parentCls = extendCls.prototype;
+                //in case of overrides the namespace is altered with mfclazz
+                //we want the final namespace
+                clzProto._nameSpace = className.replace(/(\._mfClazz)+$/,"");
                 /**
                  * @ignore
                  */
@@ -760,6 +763,8 @@ if (!myfaces._impl.core._Runtime) {
         //we only have one xml special case so webkit and opera is the
         //only detection we still need for the minimal case
         //TODO determine how to eliminate this check
+        //minimal modern should be able to cope without any browser checks
+        //at all
         //with a direct capabilities check
         _T.browser = {};
         var d  = _T.browser;

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js?rev=1202738&r1=1202737&r2=1202738&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js Wed Nov 16 15:18:53 2011
@@ -26,149 +26,152 @@
  * it emulates the xhr level2 api which is way simpler than the level1 api
  */
 
-_MF_CLS(_PFX_XHR+"engine.Xhr1", myfaces._impl.xhrCore.engine.BaseRequest,
-        /** @lends myfaces._impl.xhrCore.engine.Xhr1.prototype */
-        {
-
-            _xhrObject: null,
-            _timeoutTimer: null,
-
-            constructor_: function(params) {
-                //the constructor is empty due to the original xhr object not having anything
-                
-                this._callSuper("constructor_", params);
-                this._initDefaultFinalizableFields();
-
-                this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst;
-                this._Lang.applyArgs(this, params);
-            },
-
-            // void open(DOMString method, DOMString url, boolean async);
-            open: function(method, url, async) {
-                
-                var xhr = this._xhrObject;
-                xhr.onreadystatechange = this._Lang.hitch(this, this.onreadystatechange);
-                this.method = method || this.method;
-                this.url = url || this.url;
-                this.async = ('undefined' != typeof async) ? async : this.async;
-                xhr.open(this.method, this.url, this.async);
-            },
-
-            send: function(formData) {
-
-                var myevt = {};
-                
-                this._addProgressAttributes(myevt, 20, 100);
-                this.onloadstart(myevt);
+_MF_CLS(_PFX_XHR + "engine.Xhr1", myfaces._impl.xhrCore.engine.BaseRequest, /** @lends myfaces._impl.xhrCore.engine.Xhr1.prototype */ {
+
+    _xhrObject: null,
+    _timeoutTimer: null,
+
+    constructor_: function(params) {
+        //the constructor is empty due to the original xhr object not having anything
+
+        this._callSuper("constructor_", params);
+        this._initDefaultFinalizableFields();
+
+        this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst;
+        this._Lang.applyArgs(this, params);
+    },
+
+    // void open(DOMString method, DOMString url, boolean async);
+    open: function(method, url, async) {
+
+        var xhr = this._xhrObject;
+        xhr.onreadystatechange = this._Lang.hitch(this, this.onreadystatechange);
+        this.method = method || this.method;
+        this.url = url || this.url;
+        this.async = ('undefined' != typeof async) ? async : this.async;
+        xhr.open(this.method, this.url, this.async);
+    },
+
+    send: function(formData) {
+
+        var myevt = {};
+
+        this._addProgressAttributes(myevt, 20, 100);
+        this.onloadstart(myevt);
+        this.onprogress(myevt);
+        this._startTimeout();
+        this._xhrObject.send(formData);
+    },
+
+    setRequestHeader: function(key, value) {
+        this._xhrObject.setRequestHeader(key, value);
+    },
+
+    abort: function() {
+
+        this._xhrObject.abort();
+        this.onabort({});
+    },
+
+    _addProgressAttributes: function(evt, percent, total) {
+        //http://www.w3.org/TR/progress-events/#progressevent
+        evt.lengthComputable = true;
+        evt.loaded = percent;
+        evt.total = total;
+
+    },
+
+    onreadystatechange: function(evt) {
+        var myevt = evt || {};
+        //we have to simulate the attributes as well
+        var xhr = this._xhrObject;
+        var XHRConst = this._XHRConst;
+        try {
+        this.readyState = xhr.readyState;
+        this.status = ""+xhr.status;
+        } catch(e) {
+            //IE 6 has an internal error
+        }
+
+        switch (this.readyState) {
+
+            case  XHRConst.READY_STATE_OPENED:
+                this._addProgressAttributes(myevt, 10, 100);
+
                 this.onprogress(myevt);
-                this._startTimeout();
-                this._xhrObject.send(formData);
-            },
-
-            setRequestHeader: function(key, value) {
-                this._xhrObject.setRequestHeader(key, value);
-            },
-
-            abort: function() {
-                
-                this._xhrObject.abort();
-                this.onabort({});
-            },
-
-
-            _addProgressAttributes: function(evt, percent, total) {
-                //http://www.w3.org/TR/progress-events/#progressevent
-                evt.lengthComputable = true;
-                evt.loaded = percent;
-                evt.total = total;
-
-            },
-
-            onreadystatechange: function(evt) {
-                var myevt = evt || {};
-                //we have to simulate the attributes as well
-                var xhr = this._xhrObject;
-                var XHRConst = this._XHRConst;
-                this.readyState = xhr.readyState;
-                
-
-                switch (this.readyState) {
-
-                    case  XHRConst.READY_STATE_OPENED:
-                        this._addProgressAttributes(myevt, 10, 100);
-
-                        this.onprogress(myevt);
-                        break;
-
-                    case XHRConst.READY_STATE_HEADERS_RECEIVED:
-                        this._addProgressAttributes(myevt, 25, 100);
-
-                        this.onprogress(myevt);
-                        break;
-
-                    case XHRConst.READY_STATE_LOADING:
-                        if (this._loadingCalled) break;
-                        this._loadingCalled = true;
-                        this._addProgressAttributes(myevt, 50, 100);
-
-                        this.onprogress(myevt);
-                        break;
-
-                    case XHRConst.READY_STATE_DONE:
-                        this._addProgressAttributes(myevt, 100, 100);
-                        //xhr level1 does not have timeout handler
-                        if (this._timeoutTimer) {
-                            //normally the timeout should not cause anything anymore
-                            //but just to make sure
-                            window.clearTimeout(this._timeoutTimer);
-                            this._timeoutTimer = null;
-                        }
-                        this._transferRequestValues();
-                        this.onprogress(myevt);
-                        try {
-                            var status = xhr.status;
-                            if (status >= XHRConst.STATUS_OK_MINOR && status < XHRConst.STATUS_OK_MAJOR) {
-                                this.onload(myevt);
-                            } else {
-                                evt.type = "error";
-                                this.onerror(myevt);
-                            }
-                        } finally {
-                            this.onloadend(myevt);
-                        }
-                }
-            },
+                break;
 
-            _transferRequestValues: function() {
-                this._Lang.mixMaps(this, this._xhrObject, true, null,
-                ["responseText","responseXML","status","statusText","response"]);
-            },
+            case XHRConst.READY_STATE_HEADERS_RECEIVED:
+                this._addProgressAttributes(myevt, 25, 100);
 
-            _startTimeout: function() {
-                
-                var xhr = this._xhrObject;
-                //some browsers have timeouts in their xhr level 1.x objects implemented
-                //we leverage them whenever they exist
-                if ('undefined' != typeof xhr.timeout) {
-                    xhr.timeout = this.timeout;
-                    xhr.ontimeout = this.ontimeout;
-                    return;
-                }
+                this.onprogress(myevt);
+                break;
+
+            case XHRConst.READY_STATE_LOADING:
+                if (this._loadingCalled) break;
+                this._loadingCalled = true;
+                this._addProgressAttributes(myevt, 50, 100);
 
-                if (this.timeout == 0) return;
-                this._timeoutTimer = setTimeout(this._Lang.hitch(this, function() {
-                    if (xhr.readyState != this._XHRConst.READY_STATE_DONE) {
-                        
-                        xhr.onreadystatechange = function() {
-                        };
-                        clearTimeout(this._timeoutTimer);
-                        xhr.abort();
-                        this.ontimeout({});
+                this.onprogress(myevt);
+                break;
+
+            case XHRConst.READY_STATE_DONE:
+                this._addProgressAttributes(myevt, 100, 100);
+                //xhr level1 does not have timeout handler
+                if (this._timeoutTimer) {
+                    //normally the timeout should not cause anything anymore
+                    //but just to make sure
+                    window.clearTimeout(this._timeoutTimer);
+                    this._timeoutTimer = null;
+                }
+                this._transferRequestValues();
+                this.onprogress(myevt);
+                try {
+                    var status = xhr.status;
+                    if (status >= XHRConst.STATUS_OK_MINOR && status < XHRConst.STATUS_OK_MAJOR) {
+                        this.onload(myevt);
+                    } else {
+                        evt.type = "error";
+                        this.onerror(myevt);
                     }
-                }), this.timeout);
-            },
+                } finally {
+                    this.onloadend(myevt);
+                }
+        }
+    },
 
-            getXHRObject: function() {
-                return this._xhrObject;
+    _transferRequestValues: function() {
+        this._Lang.mixMaps(this, this._xhrObject, true, null,
+                ["responseText","responseXML","status","statusText","response"]);
+    },
+
+    _startTimeout: function() {
+
+        var xhr = this._xhrObject;
+        //some browsers have timeouts in their xhr level 1.x objects implemented
+        //we leverage them whenever they exist
+        if ('undefined' != typeof xhr.timeout) {
+            xhr.timeout = this.timeout;
+            xhr.ontimeout = this.ontimeout;
+            return;
+        }
+
+        if (this.timeout == 0) return;
+        this._timeoutTimer = setTimeout(this._Lang.hitch(this, function() {
+            if (xhr.readyState != this._XHRConst.READY_STATE_DONE) {
+
+                xhr.onreadystatechange = function() {
+                };
+                clearTimeout(this._timeoutTimer);
+                xhr.abort();
+                this.ontimeout({});
             }
-        });
\ No newline at end of file
+        }), this.timeout);
+    },
+
+    getXHRObject: function() {
+        return this._xhrObject;
+    }
+
+
+});
\ No newline at end of file