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/17 10:04:10 UTC

svn commit: r945009 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_Dom.js _util/_Queue.js xhrCore/_AjaxRequest.js xhrCore/_AjaxUtils.js xhrCore/_xhrCoreAdapter.js

Author: werpu
Date: Mon May 17 08:04:10 2010
New Revision: 945009

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

PPS Part partially cleaned up, Queue part entirely cleaned up
and now uses inheritance like it should, also added
a speed optimized queue

xhr part still needs serious cleanup.

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/_Queue.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.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=945009&r1=945008&r2=945009&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Mon May 17 08:04:10 2010
@@ -533,7 +533,7 @@ myfaces._impl.core._Runtime.singletonExt
     findFormElement : function(form, nameOrIdenitifier) {
         var eLen = form.elements.length;
         //TODO add iterator handlers here for browsers which allow dom filters and iterators
-        var _RT = myfaces._impl._util._Runtime;
+        var _RT = myfaces._impl.core._Runtime;
 
         for (var e = 0; e < eLen; e++) {
             var elem = form.elements[e];

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=945009&r1=945008&r2=945009&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Queue.js Mon May 17 08:04:10 2010
@@ -18,23 +18,23 @@ myfaces._impl.core._Runtime.extendClass(
     //license public domain
     //The trick is to simply reduce the number of slice and slice ops to a bare minimum.
 
-    _xhrQueue : null,
+    _queue : null,
     _queueSpace : 0,
     _queueSize: -1,
 
     constructor_: function() {
-        this._xhrQueue = [];
+        this._queue = [];
     },
 
     length: function() {
         // return the number of elements in the queue
-        return this._xhrQueue.length - this._queueSpace;
+        return this._queue.length - this._queueSpace;
 
     },
 
     isEmpty: function() {
         // return true if the queue is empty, and false otherwise
-        return (this._xhrQueue.length == 0);
+        return (this._queue.length == 0);
     },
 
     setQueueSize: function(newSize) {
@@ -48,7 +48,7 @@ myfaces._impl.core._Runtime.extendClass(
      * @param element the listener to be added
      */
     enqueue : function(/*function*/element) {
-        this._xhrQueue.push(element);
+        this._queue.push(element);
         //qeuesize is bigger than the limit we drop one element so that we are
         //back in line
         this._readjust();
@@ -70,7 +70,7 @@ myfaces._impl.core._Runtime.extendClass(
         var index = this.indexOf(element);
         /*found*/
         if (index != -1) {
-            this._xhrQueue.splice(index, 1);
+            this._queue.splice(index, 1);
         }
     },
 
@@ -79,17 +79,17 @@ myfaces._impl.core._Runtime.extendClass(
         var element = null;
 
         // check whether the queue is empty
-        if (this._xhrQueue.length) {
+        if (this._queue.length) {
 
             // fetch the oldest element in the queue
-            element = this._xhrQueue[this._queueSpace];
+            element = this._queue[this._queueSpace];
 
             // update the amount of space and check whether a shift should occur
             //added here a max limit of 30
-            if (++this._queueSpace * 2 >= this._xhrQueue.length || this._queueSpace > 300) {
+            if (++this._queueSpace * 2 >= this._queue.length) {
 
                 // set the queue equal to the non-empty portion of the queue
-                this._xhrQueue = this._xhrQueue.slice(this._queueSpace);
+                this._queue = this._queue.slice(this._queueSpace);
 
                 // reset the amount of space at the front of the queue
                 this._queueSpace = 0;
@@ -109,9 +109,9 @@ myfaces._impl.core._Runtime.extendClass(
      */
     each: function(closure) {
         var cnt = this._queueSpace;
-        var len = this._xhrQueue.length;
+        var len = this._queue.length;
         for (; cnt < len; cnt++) {
-            closure(this._xhrQueue[cnt]);
+            closure(this._queue[cnt]);
         }
     },
 
@@ -126,10 +126,10 @@ myfaces._impl.core._Runtime.extendClass(
     filter: function(closure) {
         var retVal = [];
         var cnt = this._queueSpace;
-        var len = this._xhrQueue.length;
+        var len = this._queue.length;
         for (; cnt < len; cnt++) {
-            if (closure(this._xhrQueue[cnt])) {
-                retVal.push(this._xhrQueue[cnt]);
+            if (closure(this._queue[cnt])) {
+                retVal.push(this._queue[cnt]);
             }
         }
         return retVal;
@@ -137,8 +137,8 @@ myfaces._impl.core._Runtime.extendClass(
 
     indexOf: function(element) {
         var cnt = this._queueSpace;
-        var len = this._xhrQueue.length;
-        while (cnt < len && this._xhrQueue[cnt] !== element) {
+        var len = this._queue.length;
+        while (cnt < len && this._queue[cnt] !== element) {
             cnt += 1;
         }
         /*found*/
@@ -147,7 +147,7 @@ myfaces._impl.core._Runtime.extendClass(
     },
 
     cleanup: function() {
-        this._xhrQueue = [];
+        this._queue = [];
         this._queueSpace = 0;
     }
 });

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=945009&r1=945008&r2=945009&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Mon May 17 08:04:10 2010
@@ -87,12 +87,8 @@ myfaces._impl.core._Runtime.extendClass(
                 this._partialIdsArray = passThrough[myfaces._impl.core.Impl._PROP_EXECUTE].split(" ");
             }
 
-            //this._queue = queue;
-            //this._context = context;
             this.response = new myfaces._impl.xhrCore._AjaxResponse(this._alarmThreshold);
             this._ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(this._alarmThreshold);
-            //this._sourceForm = sourceForm;
-            //this._passThrough = passThrough;
 
             this._requestParameters = this.getViewState();
 

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=945009&r1=945008&r2=945009&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Mon May 17 08:04:10 2010
@@ -86,7 +86,7 @@ myfaces._impl.core._Runtime.extendClass(
         var _Lang = myfaces._impl._util._Lang;
         var _Impl = myfaces._impl.core.Impl;
         var _Dom = myfaces._impl._util._Dom;
-        
+
         var nodeFilter = function(curNode) {
             //TODO bomb out if the element is not one of the input types
             //((elementTagName == "input" || elementTagName == "textarea" || elementTagName == "select") &&
@@ -118,35 +118,35 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {} partialIds -
      * @param {} stringBuffer -
      */
-    /* addNodes : function(node, insideSubmittedPart,
-     partialIds, stringBuffer) {
-     if (node != null && node.childNodes != null) {
-     var nLen = node.childNodes.length;
-     for (var i = 0; i < nLen; i++) {
-     var child = node.childNodes[i];
-     var id = child.id;
-     var elementName = child.name;
-     if (child.nodeType == 1) {
-     var isPartialSubmitContainer = ((id != null)
-     && myfaces._impl._util._Lang.arrayContains(partialIds, id));
-     if (insideSubmittedPart
-     || isPartialSubmitContainer
-     || (elementName != null
-     && elementName == myfaces._impl.core.Impl._PROP_VIEWSTATE)) {
-     // node required for PPS
-     this.addField(child, stringBuffer);
-     if (insideSubmittedPart || isPartialSubmitContainer) {
-     // check for further children
-     this.addNodes(child, true, partialIds, stringBuffer);
-     }
-     } else {
-     // check for further children
-     this.addNodes(child, false, partialIds, stringBuffer);
-     }
-     }
-     }
-     }
-     }, */
+    /*addNodes : function(node, insideSubmittedPart,
+                        partialIds, stringBuffer) {
+        if (node != null && node.childNodes != null) {
+            var nLen = node.childNodes.length;
+            for (var i = 0; i < nLen; i++) {
+                var child = node.childNodes[i];
+                var id = child.id;
+                var elementName = child.name;
+                if (child.nodeType == 1) {
+                    var isPartialSubmitContainer = ((id != null)
+                            && myfaces._impl._util._Lang.arrayContains(partialIds, id));
+                    if (insideSubmittedPart
+                            || isPartialSubmitContainer
+                            || (elementName != null
+                            && elementName == myfaces._impl.core.Impl._PROP_VIEWSTATE)) {
+                        // node required for PPS
+                        this.addField(child, stringBuffer);
+                        if (insideSubmittedPart || isPartialSubmitContainer) {
+                            // check for further children
+                            this.addNodes(child, true, partialIds, stringBuffer);
+                        }
+                    } else {
+                        // check for further children
+                        this.addNodes(child, false, partialIds, stringBuffer);
+                    }
+                }
+            }
+        }
+    },*/
 
     /**
      * add a single field to stringbuffer for param submission
@@ -154,7 +154,7 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {} strBuf -
      */
     encodeElement : function(element, strBuf) {
-        var elementName = (null != element.name || 'undefined' != typeof element.name) ? element.name: element.id;
+        var elementName = (null != element.name || 'undefined' != typeof element.name) ? element.name : element.id;
         var elementTagName = element.tagName.toLowerCase();
         var elementType = element.type;
         if (elementType != null) {

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js?rev=945009&r1=945008&r2=945009&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js Mon May 17 08:04:10 2010
@@ -23,7 +23,7 @@ myfaces._impl.core._Runtime.extendClass(
     /**
      * a singleton queue
      */
-    _xhrQueue: myfaces._impl.xhrCore._RQInstance,
+    _queue: myfaces._impl.xhrCore._RQInstance,
     _exception: new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", "ERROR"),
 
     /**
@@ -35,8 +35,8 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {Map} passThroughValues values to be passed through
      **/
     xhrQueuedPost : function(source, sourceForm, context, passThroughValues) {
-        this._xhrQueue.enqueue(
-                new myfaces._impl.xhrCore._AjaxRequest(source, sourceForm, context, passThroughValues,this._xhrQueue));
+        this._queue.enqueue(
+                new myfaces._impl.xhrCore._AjaxRequest(source, sourceForm, context, passThroughValues,this._queue));
     },
     /*
     _stdErrorHandler: function(request, context,sourceClass, func, exception) {
@@ -55,6 +55,6 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {XmlHttpRequest} context - the ajax context
      */
     response : function(request, context) {
-        this._xhrQueue._curReq.response.processResponse(request, context);
+        this._queue._curReq.response.processResponse(request, context);
     }
 });