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/11 13:22:31 UTC

svn commit: r1200847 - in /myfaces/core/branches/2.0.x/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/

Author: werpu
Date: Fri Nov 11 12:22:30 2011
New Revision: 1200847

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


Added:
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomExperimental.js
Modified:
    myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml
    myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-experimental.xml
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js
    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/jsf-uncompressed.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
    myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js

Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml Fri Nov 11 12:22:30 2011
@@ -82,6 +82,7 @@
 
 
                 <include>**/_impl/xhrCore/_AjaxRequest.js</include>
+                <include>**/_impl/xhrCore/_ExtAjaxRequest.js</include>
 
                 <!-- this is pure 2.2 functionality -->
                 <include>**/_impl/xhrCore/_IFrameRequest.js</include>

Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-experimental.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-experimental.xml?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-experimental.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-experimental.xml Fri Nov 11 12:22:30 2011
@@ -31,7 +31,7 @@
                 <include>**/_impl/_util/_DomExperimental.js</include>
                 <include>**/_impl/_util/_ExtDom.js</include>
                 <include>**/_impl/xhrCore/engine/IFrame.js</include>
-                <include>**/_impl/xhrCore/_AjaxRequest.js</include>
+                <include>**/_impl/xhrCore/_ExtAjaxRequest.js</include>
                 <include>**/_impl/xhrCore/_IFrameRequest.js</include>
                 <include>**/_impl/xhrCore/_PartialSubmitUtils.js</include>
                 <include>**/_impl/xhrCore/_ExtTransports.js</include>

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Fri Nov 11 12:22:30 2011
@@ -477,32 +477,29 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, 
      * @param markup
      */
     _buildTableNodes: function(item, markup) {
-        var evalNodes,
-                itemNodeName = (item.nodeName || item.tagName).toLowerCase(),
-                probe = this.getDummyPlaceHolder(); //document.createElement("div");
+        var itemNodeName = (item.nodeName || item.tagName).toLowerCase(),
+                probe = document.createElement("div");
 
-        if (itemNodeName == "td") {
-            probe.innerHTML = "<table><tbody><tr><td></td></tr></tbody></table>";
-        } else {
-            probe.innerHTML = ["<table><" , itemNodeName , "></" , itemNodeName , ">" , "</table>"].join("");
+        var tmpNodeName = itemNodeName;
+        var depth = 0;
+        while (tmpNodeName != "table") {
+            item = item.parentNode;
+            tmpNodeName = (item.nodeName || item.tagName).toLowerCase();
+            depth++;
         }
-        var depth = this._determineDepth(probe);
 
-        this._removeChildNodes(probe, false);
-        probe.innerHTML = "";
-
-        var dummyPlaceHolder = this.getDummyPlaceHolder();//document.createElement("div");
+        var dummyPlaceHolder = document.createElement("div");
         if (itemNodeName == "td") {
             dummyPlaceHolder.innerHTML = "<table><tbody><tr>" + markup + "</tr></tbody></table>";
         } else {
             dummyPlaceHolder.innerHTML = "<table>" + markup + "</table>";
         }
-        evalNodes = dummyPlaceHolder;
+
         for (var cnt = 0; cnt < depth; cnt++) {
-            evalNodes = evalNodes.childNodes[0];
+            dummyPlaceHolder = dummyPlaceHolder.childNodes[0];
         }
-        evalNodes = (evalNodes.parentNode) ? evalNodes.parentNode.childNodes : null;
-        return this.detach(evalNodes);
+
+        return this.detach(dummyPlaceHolder.childNodes);
     },
 
     _removeChildNodes: function(node, breakEventsOpen) {
@@ -510,17 +507,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, 
         node.innerHTML = "";
     },
 
-    _determineDepth: function(probe) {
-        var depth = 0;
-        var newProbe = probe;
-        for (; newProbe &&
-                       newProbe.childNodes &&
-                       newProbe.childNodes.length &&
-                       newProbe.nodeType == 1; depth++) {
-            newProbe = newProbe.childNodes[0];
-        }
-        return depth;
-    },
+
 
     _removeNode: function(node, breakEventsOpen) {
         if (!node) return;

Added: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomExperimental.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomExperimental.js?rev=1200847&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomExperimental.js (added)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomExperimental.js Fri Nov 11 12:22:30 2011
@@ -0,0 +1,48 @@
+if (_MF_SINGLTN) {
+    _MF_SINGLTN(_PFX_UTIL + "_DomExperimental", myfaces._impl._util._Dom, /** @lends myfaces._impl._util._Dom.prototype */ {
+        constructor_: function() {
+            this._callSuper("constructor_");
+            myfaces._impl._util._Dom = this;
+        },
+
+        /**
+         * fetches the window id for the current request
+         * note, this is a preparation method for jsf 2.2
+         *
+         * todo move this into the experimental part
+         */
+        getWindowId: function() {
+            var href = window.location.href;
+            var windowId = "windowId";
+            var regex = new RegExp("[\\?&]" + windowId + "=([^&#\\;]*)");
+            var results = regex.exec(href);
+            return (results != null) ? results[1] : null;
+        },
+
+        html5FormDetection: function(item) {
+            var browser = this._RT.browser;
+            //ie shortcut, not really needed but speeds things up
+            if (browser.isIEMobile && browser.isIEMobile <= 8) {
+                return null;
+            }
+            var elemForm = this.getAttribute(item, "form");
+            return (elemForm) ? this.byId(elemForm) : null;
+        },
+
+        //TODO move this into the extended features part
+        isMultipartCandidate: function(executes) {
+            if (this._Lang.isString(executes)) {
+                executes = this._Lang.strToArray(executes, /\s+/);
+            }
+
+            for (var exec in executes) {
+                var element = this.byId(executes[exec]);
+                var inputs = this.findByTagName(element, "input", true);
+                for (var key in inputs) {
+                    if (this.getAttribute(inputs[key], "type") == "file") return true;
+                }
+            }
+            return false;
+        }
+    });
+}

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js Fri Nov 11 12:22:30 2011
@@ -211,6 +211,18 @@ _MF_SINGLTN(_PFX_UTIL+"DomQuirks", myfac
 
     },
 
+    _determineDepth: function(probe) {
+        var depth = 0;
+        var newProbe = probe;
+        for (; newProbe &&
+                       newProbe.childNodes &&
+                       newProbe.childNodes.length &&
+                       newProbe.nodeType == 1; depth++) {
+            newProbe = newProbe.childNodes[0];
+        }
+        return depth;
+    },
+
      //now to another nasty issue:
     //for ie we have to walk recursively over all nodes:
     //http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx

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=1200847&r1=1200846&r2=1200847&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 Fri Nov 11 12:22:30 2011
@@ -82,7 +82,7 @@ _MF_SINGLTN(_PFX_CORE+"Impl", _MF_OBJECT
 
     /*blockfilter for the passthrough filtering, the attributes given here
      * will not be transmitted from the options into the passthrough*/
-    _BLOCKFILTER: {onerror: true, onevent: true, render: true, execute: true, myfaces: true},
+    _BLOCKFILTER: {onerror: 1, onevent: 1, render: 1, execute: 1, myfaces: 1},
 
 
 
@@ -551,17 +551,15 @@ _MF_SINGLTN(_PFX_CORE+"Impl", _MF_OBJECT
         this._evtListeners.broadcastEvent(eventData);
     },
 
+
     /**
-     * processes the ajax response if the ajax request completes successfully
-     * this is the case for non queued outside calls which are triggered by calling response
-     * themselves and hence the case according to the spec
-     *
-     * @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
+     * Spec. 13.3.3
+     * Examining the response markup and updating the DOM tree
+     * @param {XMLHttpRequest} request - the ajax request
+     * @param {Object} context - the ajax context
      */
     response : function(request, context) {
-        this._transport.response(request, context);
+        this._RT.getLocalOrGlobalConfig(context, "responseHandler", myfaces._impl.xhrCore._AjaxResponse).processResponse(request, context);
     },
 
     /**

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Fri Nov 11 12:22:30 2011
@@ -53,6 +53,8 @@ if (!window.jsf) {
 
 
     _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8", false);
+    _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_ExtAjaxRequest.js']}", null, null, "UTF-8", false);
+
     _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_IFrameRequest.js']}", null, null, "UTF-8", false);
     _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8", false);
     _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8", false);

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Fri Nov 11 12:22:30 2011
@@ -62,9 +62,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
     /** xhr object, internal param */
     _xhr: null,
 
-    /** response object which is exposed to the queue */
-    _response: null,
-
     /** predefined method */
     _ajaxType:"POST",
 
@@ -112,9 +109,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
             var xhrCore = myfaces._impl.xhrCore;
             this._AJAXUTIL = xhrCore._AjaxUtils;
 
-            //we cannot eliminate it due to the direct reference to its request the response needs
-            //at least for now, in the long run we can and must
-            this._response = xhrCore._AjaxResponse;
         } catch (e) {
             //_onError
             this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "constructor", e);
@@ -155,13 +149,15 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
             xhr.open(this._ajaxType, targetURL +
                     ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
                     , true);
+
             xhr.timeout = this._timeout || 0;
+
             var contentType = this._contentType;
             if (this._encoding) {
                 contentType = contentType + "; charset:" + this._encoding;
             }
 
-            xhr.setRequestHeader(this._CONTENT_TYPE, this._contentType);
+            xhr.setRequestHeader(this._CONTENT_TYPE, contentType);
             xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
 
             this._sendEvent("BEGIN");
@@ -192,13 +188,16 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
             this._sendEvent("COMPLETE");
             //now we have to reroute into our official api
             //because users might want to decorate it, we will split it apart afterwards
-            context._mfInternal = context._mfInternal || {};
-            context._mfInternal._mfRequest = this;
 
+            context._mfInternal = context._mfInternal || {};
             jsf.ajax.response((xhr.getXHRObject) ? xhr.getXHRObject() : xhr, context);
 
             //an error in the processing has been raised
-            if(!context._mfInternal.internalError) {
+            //TODO move all the error callbacks from response into
+            //a thrown exception best with a message history so
+            //that we have a message trace
+            //target 2.1.5
+            if (!context._mfInternal.internalError) {
                 this._sendEvent("SUCCESS");
             }
         } catch (e) {
@@ -235,7 +234,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
     },
 
     ontimeout: function(evt) {
-
         try {
             //we issue an event not an error here before killing the xhr process
             this._sendEvent("TIMEOUT_EVENT");
@@ -253,15 +251,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
     },
 
     _getTransport: function() {
-        var _Rt = myfaces._impl.core._Runtime;
-        //same interface between 1 and 2, in the worst case
-        //so we can make a drop in replacement, on level2
-        //we have one layer less hence we can work directly
-        //on the xhr object, on level2 we have our engine
-        //emulation layer which thunks back into level1
-        //for all calls
 
-        var xhr = myfaces._impl.core._Runtime.getXHRObject();
+        var xhr = this._RT.getXHRObject();
         //the current xhr level2 timeout w3c spec is not implemented by the browsers yet
         //we have to do a fallback to our custom routines
 
@@ -271,7 +262,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
         //no timeout we can skip the emulation layer
         //    return xhr;
         //}
-
         return new myfaces._impl.xhrCore.engine.Xhr1({xhrObject: xhr});
     },
 
@@ -289,29 +279,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
      * which keeps the final Send Representation of the
      */
     getFormData : function() {
-        var _AJAXUTIL = this._AJAXUTIL,
-                _Lang = this._Lang,
-                myfacesOptions = this._context.myfaces,
-                ret = null,
-                source = this._source,
-                sourceForm = this._sourceForm;
-
-        //now this is less performant but we have to call it to allow viewstate decoration
-        if (!this._partialIdsArray || !this._partialIdsArray.length) {
-            var viewState = jsf.getViewState(sourceForm);
-            ret = _Lang.createFormDataDecorator(viewState);
-
-            //just in case the source item is outside of the form
-            //only if the form override is set we have to append the issuing item
-            //otherwise it is an element of the parent form
-            if (source && myfacesOptions && myfacesOptions.form)
-                _AJAXUTIL.appendIssuingItem(source);
-        } else {
-            ret = _Lang.createFormDataDecorator(new Array());
-            _AJAXUTIL.encodeSubmittableFields(ret, sourceForm, this._partialIdsArray);
-            if (source && myfacesOptions && myfacesOptions.form)
-                _AJAXUTIL.appendIssuingItem(source);
-        }
+        var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces;
+        var ret = this._Lang.createFormDataDecorator(jsf.getViewState(this._sourceForm));
 
         return ret;
     },

Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js?rev=1200847&r1=1200846&r2=1200847&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js Fri Nov 11 12:22:30 2011
@@ -64,8 +64,6 @@ _MF_SINGLTN(_PFX_XHR + "_Transports", _M
      */
     _q: new myfaces._impl.xhrCore._AjaxRequestQueue(),
 
-
-
     /**
      * xhr post with enqueuing as defined by the jsf 2.0 specification
      *
@@ -82,38 +80,6 @@ _MF_SINGLTN(_PFX_XHR + "_Transports", _M
     },
 
     /**
-     * Spec. 13.3.3
-     * Examining the response markup and updating the DOM tree
-     * @param {XMLHttpRequest} request - the ajax request
-     * @param {Object} context - the ajax context
-     */
-    response : function(request, context) {
-
-        //TODO we can eliminate this method in favor of an impl specific code where
-        //the response is weakly bound
-
-        var internalContext = context._mfInternal;
-
-        //the normal usecase is that the request knows about its response
-        //which normally is temporary stored within the _mfRequest object
-        //(aka call from a finished request)
-        //if no _mfRequest object is given which means an external call we
-        //have a call from the outside
-
-        //TODO check if we cannot eliminate the _mfRequest object in the long run
-        //given we have to pass a request object anyway
-
-        var ajaxObj = (internalContext && internalContext._mfRequest) || new (this._getAjaxReqClass(context))({xhr: request, context: context});
-        //ie gc fix
-        if (internalContext && internalContext._mfRequest) {
-            internalContext._mfRequest = null;
-            delete internalContext._mfRequest;
-        }
-
-        ajaxObj._response.processResponse(request, context);
-    },
-
-    /**
      * creates the arguments map and
      * fetches the config params in a proper way in to
      * deal with them in a flat way (from the nested context way)