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 2009/04/20 09:13:21 UTC

svn commit: r766601 - in /myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces: _impl/_util/ _impl/core/ _impl/xhrCore/ api/

Author: werpu
Date: Mon Apr 20 07:13:20 2009
New Revision: 766601

URL: http://svn.apache.org/viewvc?rev=766601&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2194
https://issues.apache.org/jira/browse/MYFACES-2192
https://issues.apache.org/jira/browse/MYFACES-2200
https://issues.apache.org/jira/browse/MYFACES-2174

Thank you Alexander Bell and Ganesh Jung for providing the patches...

Modified:
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Mon Apr 20 07:13:20 2009
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- * Author: Ganesh Jung (latest modification by $Author: werpu $)
- * Version: $Revision: 1.8 $ $Date: 2009/04/17 13:25:44 $
+ * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
+ * Version: $Revision: 1.9 $ $Date: 2009/04/18 17:19:12 $
  *
  */
 
@@ -32,9 +32,11 @@
  * [STATIC]
  * Run through the given Html item and execute the inline scripts
  * (IE doesn't do this by itself)
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
  * @param {HtmlElement} item
  */
-myfaces._impl._util._Utils.runScripts = function(item) {
+myfaces._impl._util._Utils.runScripts = function(request, context, item) {
     if (item.nodeType == 1) { // only if it's an element node
         if (item.tagName.toLowerCase() == 'script') {
             try {
@@ -57,12 +59,12 @@
                 }
                 window.execScript(test); // run the script
             } catch (e) {
-                myfaces._impl.xhrCore._Exception.throwNewError ("Utils", "runScripts", e);
+                myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "runScripts", e);
             }
         } else {
             var child = item.firstChild;
             while (child) {
-                myfaces._impl._util._Utils.runScripts(child);
+                myfaces._impl._util._Utils.runScripts(request, context, child);
                 child = child.nextSibling;
             }
         }
@@ -72,11 +74,11 @@
 /**
  * Simple delete on an existing item
  */
-myfaces._impl._util._Utils.deleteItem = function(itemIdToReplace) {
+myfaces._impl._util._Utils.deleteItem = function(request, context, itemIdToReplace) {
     var item = document.getElementById(itemIdToReplace);
     if (item == null) {
         myfaces._impl.xhrCore._Exception.throwNewWarning
-        ("Utils", "deleteItem", "Unknown Html-Component-ID: " + itemIdToReplace);
+        (request, context, "Utils", "deleteItem", "Unknown Html-Component-ID: " + itemIdToReplace);
         return;
     }
 
@@ -86,18 +88,21 @@
 /**
  * [STATIC]
  * Replaces HTML elements through others
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
  * @param {String|node} itemIdToReplace - ID of the element to replace
  * @param {String} newTag - the new tag
  * @param {HTML Element} form - form element that is parent of the element
  */
-myfaces._impl._util._Utils.replaceHtmlItem = function(itemIdToReplace, newTag, form) {
+myfaces._impl._util._Utils.replaceHtmlItem = function(request, context, itemIdToReplace, newTag, form) {
     try {
 
 
-        var item = (itemIdToReplace instanceof Node) ? itemIdToReplace : myfaces._impl._util._Utils.getElementFromForm(itemIdToReplace, form);
+        var item = (itemIdToReplace instanceof Node) ? itemIdToReplace :
+            myfaces._impl._util._Utils.getElementFromForm(request, context, itemIdToReplace, form);
         if (item == null) {
             myfaces._impl.xhrCore._Exception.throwNewWarning
-            ("Utils", "replaceHTMLItem", "Unknown Html-Component-ID: " + itemIdToReplace);
+            (request, context, "Utils", "replaceHTMLItem", "Unknown Html-Component-ID: " + itemIdToReplace);
             return;
         }
 
@@ -112,14 +117,14 @@
                 item.insertAdjacentHTML('beforeBegin', newTag);
             }
             if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
-                myfaces._impl._util._Utils.runScripts(item.previousSibling);
+                myfaces._impl._util._Utils.runScripts(request, context, item.previousSibling);
             }
         }
 
         // and remove the old item
         item.parentNode.removeChild(item);
     } catch (e) {
-        myfaces._impl.xhrCore._Exception.throwNewError ("Utils", "replaceHTMLItem", e);
+        myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "replaceHTMLItem", e);
     }
 };
 
@@ -208,11 +213,13 @@
  * the same id but are located in different forms -> MyFaces 1.1.4 two forms ->
  * 2 inputHidden fields with ID jsf_tree_64 & jsf_state_64 ->
  * http://www.arcknowledge.com/gmane.comp.jakarta.myfaces.devel/2005-09/msg01269.html
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
  * @param {String} itemId - ID of the HTML element located inside the form
  * @param {Html-Element} form - form element containing the element
  * @return {Html-Element} - return the element if found else null
  */
-myfaces._impl._util._Utils.getElementFromForm = function(itemId, form) {
+myfaces._impl._util._Utils.getElementFromForm = function(request, context, itemId, form) {
     try {
         
 
@@ -231,17 +238,19 @@
         // (kann be null if element doesn't exist)
         return document.getElementById(itemId);
     } catch (e) {
-        myfaces._impl.xhrCore._Exception.throwNewError ("Utils", "getElementFromForm", e);
+        myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "getElementFromForm", e);
     }
 };
 
 /**
  * [STATIC]
  * gets a parent of an item with a given tagname
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
  * @param {HtmlElement} item - child element
  * @param {String} parentName - TagName of parent element
  */
-myfaces._impl._util._Utils.getParent = function(item, parentName) {
+myfaces._impl._util._Utils.getParent = function(request, context, item, parentName) {
     try {
         // parent tag parentName suchen
         var parentItem = item.parentNode;
@@ -253,11 +262,11 @@
             return parentItem;
         } else {
             myfaces._impl.xhrCore._Exception.throwNewWarning
-            ("Utils", "getParent", "The item has no parent with type <" + parentName + ">");
+            (request, context, "Utils", "getParent", "The item has no parent with type <" + parentName + ">");
             return null;
         }
     } catch (e) {
-        myfaces._impl.xhrCore._Exception.throwNewError ("Utils", "getParent", e);
+        myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "getParent", e);
     }
 };
 

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Mon Apr 20 07:13:20 2009
@@ -36,19 +36,39 @@
 
     /*CONSTANTS*/
 
-    myfaces._impl.core._jsfImpl.prototype._PROP_PARTIAL_SOURCE = "javax.faces.partial.source";
-    myfaces._impl.core._jsfImpl.prototype._PROP_VIEWSTATE = "javax.faces.viewState";
-    myfaces._impl.core._jsfImpl.prototype._PROP_AJAX = "javax.faces.partial.ajax";
-    myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE = "javax.faces.partial.execute";
-    myfaces._impl.core._jsfImpl.prototype._PROP_RENDER = "javax.faces.partial.render";
-    myfaces._impl.core._jsfImpl.prototype._PROP_EVENT = "javax.faces.partial.event";
-
     /*internal identifiers for options*/
     myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_ALL = "@all";
     myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_NONE = "@none";
     myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_THIS = "@this";
     myfaces._impl.core._jsfImpl.prototype._OPT_IDENT_FORM = "@form";
 
+    /*
+     * [STATIC] constants
+     */
+
+    myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE = "javax.faces.partial.source";
+    myfaces._impl.core._jsfImpl._PROP_VIEWSTATE = "javax.faces.ViewState";
+    myfaces._impl.core._jsfImpl._PROP_AJAX = "javax.faces.partial.ajax";
+    myfaces._impl.core._jsfImpl._PROP_EXECUTE = "javax.faces.partial.execute";
+    myfaces._impl.core._jsfImpl._PROP_RENDER = "javax.faces.partial.render";
+    myfaces._impl.core._jsfImpl._PROP_EVENT = "javax.faces.partial.event";
+
+    /* message types */
+    myfaces._impl.core._jsfImpl._MSG_TYPE_ERROR       = "error";
+    myfaces._impl.core._jsfImpl._MSG_TYPE_EVENT       = "event";
+
+    /* event emitting stages */
+    myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN     = "begin";
+    myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE  = "complete";
+    myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS   = "success";
+
+    /*ajax errors spec 14.4.2*/
+    myfaces._impl.core._jsfImpl._ERROR_HTTPERROR      = "httpError";
+    myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE = "emptyResponse";
+    myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML   = "malformedXML";
+    myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR   = "serverError";
+    myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR   = "clientError";
+
     /**
      * collect and encode data for a given form element (must be of type form)
      * find the javax.faces.ViewState element and encode its value as well!
@@ -112,18 +132,6 @@
     }
 
     /**
-     * Captures the event arguments according to the list in the specification
-     */
-    myfaces._impl.core._jsfImpl.prototype._caputureEventArgs = function(/*Dom node*/node, /*event*/ obj) {
-        /*
-         * TODO encode the rest of the arguments
-         * once it is clear what has to be done here
-         */
-        var retVal = {};
-        return retVal;
-    };
-
-    /**
      * this function has to send the ajax requests
      *
      * following request conditions must be met:
@@ -158,31 +166,52 @@
         /*assert if the onevent is set and once if it is set it must be of type function*/
         this._assertFunction(options.onevent);
 
+        /*
+         * We make a copy of our options because
+         * we should not touch the incoming params!
+         */
+        var passThroughArguments = JSF2Utils.mixMaps({}, options, true);
+
+        /*additional passthrough cleanup*/
+        /*ie6 supportive code to prevent browser leaks*/
+        passThroughArguments.onevent = null;
+        delete passThroughArguments.onevent;
+        /*ie6 supportive code to prevent browser leaks*/
+        passThroughArguments.onerror = null;
+        delete passThroughArguments.onerror;
+
+        if ('undefined' != typeof event && null != event) {
+            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EVENT] = event.type;
+        }
+
+        /**
+         * ajax pass through context with the source
+         * onevent and onerror
+         */
+        var ajaxContext = {};
+        ajaxContext.source = element;
+        ajaxContext.onevent = options.onevent;
+        ajaxContext.onerror = options.onerror;
+
         /**
-         * fetch the parent form first
+         * fetch the parent form
          */
-        var sourceForm = myfaces._impl._util._Utils.getParent(element, "form");
+        var sourceForm = myfaces._impl._util._Utils.getParent(null, ajaxContext, element, "form");
 
         if ('undefined' == typeof sourceForm || null == sourceForm) {
             sourceForm = document.forms[0];
         }
 
-        /*
-         * We make a copy of our options because
-         * we should not touch the incoming params!
-         */
-        var passThroughArguments = JSF2Utils.mixMaps({}, options, true);
-
-        /*
+/*
          * binding contract the javax.faces.partial.source must be
          * set according to the december 2008 preview
          */
-        passThroughArguments[this._PROP_PARTIAL_SOURCE] = element.id;
+        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_PARTIAL_SOURCE] = element.id;
 
         /*
          * javax.faces.partial.ajax must be set to true
          */
-        passThroughArguments[this._PROP_AJAX] = true;
+        passThroughArguments[myfaces._impl.core._jsfImpl._PROP_AJAX] = true;
 
         /**
          * if execute or render exist
@@ -198,16 +227,16 @@
                 execString = execString.replace(this._OPT_IDENT_FORM, sourceForm.id);
                 execString = execString.replace(this._OPT_IDENT_THIS, element.id);
 
-                passThroughArguments[this._PROP_EXECUTE] = execString;
+                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = execString;
             } else if (execAll) {
-                passThroughArguments[this._PROP_EXECUTE] = this._OPT_IDENT_ALL;
+                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = this._OPT_IDENT_ALL;
             }
 
             passThroughArguments.execute = null;
             /*remap just in case we have a valid pointer to an existing object*/
             delete passThroughArguments.execute;
         } else {
-            passThroughArguments[this._PROP_EXECUTE] = element.id;
+            passThroughArguments[myfaces._impl.core._jsfImpl._PROP_EXECUTE] = element.id;
         }
         if (JSF2Utils.exists(passThroughArguments, "render")) {
             var renderString = JSF2Utils.arrayToString(passThroughArguments.render, ' ');
@@ -216,42 +245,15 @@
             if (!renderNone && !renderAll) {
                 renderString = renderString.replace(this._OPT_IDENT_FORM, sourceForm.id);
                 renderString = renderString.replace(this._OPT_IDENT_THIS, element.id);
-                passThroughArguments[this._PROP_RENDER] = JSF2Utils.arrayToString(passThroughArguments.render, ' ');
+                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_RENDER] = JSF2Utils.arrayToString(passThroughArguments.render, ' ');
                 passThroughArguments.render = null;
             } else if (renderAll) {
-                passThroughArguments[this._PROP_RENDER] = this._OPT_IDENT_ALL;
+                passThroughArguments[myfaces._impl.core._jsfImpl._PROP_RENDER] = this._OPT_IDENT_ALL;
 
             }
             delete passThroughArguments.render;
         }
 
-        /*additional passthrough cleanup*/
-        /*ie6 supportive code to prevent browser leaks*/
-        passThroughArguments.onevent = null;
-        delete passThroughArguments.onevent;
-        /*ie6 supportive code to prevent browser leaks*/
-        passThroughArguments.onerror = null;
-        delete passThroughArguments.onerror;
-
-        var extractedEventArguments = this._caputureEventArgs(element, event);
-
-        if ('undefined' != typeof event && null != event) {
-            passThroughArguments[this._PROP_EVENT] = event.type;
-        }
-
-        /*we mixin the event params but do not override existing ones!*/
-
-        passThroughArguments = JSF2Utils.mixMaps(passThroughArguments, extractedEventArguments, false);
-
-        /**
-         * ajax pass through context with the source
-         * onevent and onerror
-         */
-        var ajaxContext = {};
-        ajaxContext.source = element;
-        ajaxContext.onevent = options.onevent;
-        ajaxContext.onerror = options.onerror;
-
        //implementation specific options are added to the context for further processing
         if('undefined' != typeof passThroughArguments.myfaces && null != passThroughArguments.myfaces) {
             ajaxContext.myfaces = passThroughArguments.myfaces;
@@ -283,13 +285,17 @@
      */
     myfaces._impl.core._jsfImpl.prototype.sendError = function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage) {
         var eventData = {};
-        eventData.type = this._MSG_TYPE_ERROR;
+        eventData.type = myfaces._impl.core._jsfImpl._MSG_TYPE_ERROR;
 
         eventData.name = name;
-        eventData.source = context.source;
-        eventData.responseXML = request.responseXML;
-        eventData.responseText = request.responseText;
-        eventData.responseCode = request.status;
+        try {
+            eventData.source = context.source;
+            eventData.responseXML = request.responseXML;
+            eventData.responseText = request.responseText;
+            eventData.responseCode = request.status;
+        } catch (e) {
+            // silently ignore: user can find out by examining the event data
+        }
 
         /**/
         if (myfaces._impl._util._LangUtils.exists(context, "onerror")) {
@@ -307,16 +313,21 @@
      * TODO make sure this method also occurrs in the specs
      * otherwise simply pull it
      */
-    myfaces._impl.core._jsfImpl.prototype.sendEvent = function sendEvent(/*Object*/request, /*Object*/ context, /*even name*/ name) {
+    myfaces._impl.core._jsfImpl.prototype.sendEvent = function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
         var eventData = {};
-        eventData.type = this._MSG_TYPE_EVENT;
+        eventData.type = myfaces._impl.core._jsfImpl._MSG_TYPE_EVENT;
 
         eventData.name = name;
         eventData.source = context.source;
-        if (name !== this._AJAX_STAGE_BEGIN) {
-            eventData.responseXML = request.responseXML;
-            eventData.responseText = request.responseText;
-            eventData.responseCode = request.status;
+        if (name !== myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN) {
+            try {
+                eventData.responseXML = request.responseXML;
+                eventData.responseText = request.responseText;
+                eventData.responseCode = request.status;
+            } catch (e) {
+                jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, "ErrorRetrievingResponse",
+                    "Parts of the response couldn't be retrieved when constructing the event data: " + e);
+            }
         }
 
         /**/
@@ -336,12 +347,9 @@
      */
     myfaces._impl.core._jsfImpl.prototype.response = function(request, context) {
         this._requestHandler._ajaxResponse(request, context);
-        /**
-         * TODO #62
-         * https://issues.apache.org/jira/browse/MYFACES-2114
-         */
     };
-    /**
+
+/**
      * @return the project stage also emitted by the server:
      * it cannot be cached and must be delivered over the server
      *

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Mon Apr 20 07:13:20 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.5 $ $Date: 2009/04/13 19:50:24 $
+ * Version: $Revision: 1.8 $ $Date: 2009/04/19 06:46:13 $
  *
  */
 
@@ -32,10 +32,11 @@
 	try {
 		this.m_contentType = "application/x-www-form-urlencoded";
 		this.m_source = source;
-		this.m_request = null;
+		this.m_xhr = null;
         // myfaces parameters
         this.m_partialIdsArray = null;
         var errorlevel = 'NONE';
+        this.m_queuesize = -1;
         if (typeof context != 'undefined'
             && context != null
             && typeof context.myfaces != 'undefined'
@@ -43,65 +44,59 @@
             if (typeof context.myfaces.errorlevel != 'undefined'
                 && context.myfaces.errorlevel != null)
                 errorlevel = context.myfaces.errorlevel;
+            if (typeof context.myfaces.queuesize != 'undefined'
+                && context.myfaces.queuesize != null)
+                this.m_queuesize = context.myfaces.queuesize;
             if (typeof context.myfaces.pps != 'undefined'
                 && context.myfaces.pps
-                && typeof passThrough.execute != 'undefined'
-                && passThrough.execute != null
-                && passThrough.execute.length > 0) {
-                this.m_partialIdsArray = passThrough.execute.split(" ");
+                && typeof passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE] != 'undefined'
+                && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE] != null
+                && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
+                this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
             }
         }
         this.m_context = context;
 		this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
 		this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
-		this.m_requestQueue = null;
 		this.m_sourceForm = sourceForm;
         this.m_passThrough = passThrough;
+        this.m_requestParameters = this.getViewState();
+        for (var key in this.m_passThrough) {
+            this.m_requestParameters = this.m_requestParameters +
+                "&" + encodeURIComponent(key) +
+                "=" + encodeURIComponent(this.m_passThrough[key]);
+        }
 	} catch (e) {
-		this.m_exception.throwError("Ctor", e);
+		this.m_exception.throwError(null, context, "Ctor", e);
 	}
 };
 
 /**
- * Prepares an Ajax request with the request parameters
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.prepare = function() {
-    // read data from form
-    this.m_requestParameters = jsf.getViewState(this.m_sourceForm);
-    for (var key in this.m_passThrough) {
-        this.m_requestParameters = this.m_requestParameters +
-            "&" + encodeURIComponent(key) +
-            "=" + encodeURIComponent(this.m_passThrough[key]);
-    }
-    return this;
-}
-/**
  * Sends an Ajax request
  * @param {RequestQueue} requestQueue - Queue object to trigger next request
  */
 
-myfaces._impl.xhrCore._AjaxRequest.prototype.send = function(requestQueue) {
+myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
 	try {
-		this.m_requestQueue = requestQueue;
-
 		if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
 			// request object for Internet Explorer
 			try {
-				this.m_request = new ActiveXObject("Msxml2.XMLHTTP");
+				this.m_xhr = new ActiveXObject("Msxml2.XMLHTTP");
 			} catch (e) {
-				this.m_request = new ActiveXObject('Microsoft.XMLHTTP');
+				this.m_xhr = new ActiveXObject('Microsoft.XMLHTTP');
 			}
 		} else {
 			// request object for standard browser
-			this.m_request = new XMLHttpRequest();
+			this.m_xhr = new XMLHttpRequest();
 		}
-		this.m_request.open("POST", this.m_sourceForm.action, true);
-		this.m_request.setRequestHeader("Content-Type", this.m_contentType);
-		this.m_request.setRequestHeader("Faces-Request", "partial/ajax");
-		this.m_request.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
-		this.m_request.send(this.m_requestParameters);
+		this.m_xhr.open("POST", this.m_sourceForm.action, true);
+		this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
+		this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
+		this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
+        jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
+		this.m_xhr.send(this.m_requestParameters);
 	} catch (e) {
-		this.m_exception.throwError("send", e);
+		this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
 	}
 };
 
@@ -110,68 +105,35 @@
  * triggered by RequestQueue
  */
 myfaces._impl.xhrCore._AjaxRequest.prototype.requestCallback = function() {
-	try {
-		if (this.isComplete() == true) {
-			this.m_response.processResponse(this.m_request, this.m_sourceForm, this.m_context);
-			this.m_requestQueue.processQueue();
-		} else if (this.isPending() == false && this.isFailed() == true) {
-			this.m_exception.throwWarning("requestCallback",
-					"Request failed.\nReason " + this.getHtmlStatusText());
-		}
+    var READY_STATE_DONE = 4;
+    try {
+
+        if (this.m_xhr.readyState == READY_STATE_DONE) {
+            if (this.m_xhr.status >= 200 || this.m_xhr.status < 300) {
+                jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
+                jsf.ajax.response(this.m_xhr, this.m_context);
+                jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS);
+                myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
+            } else {
+                jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
+                jsf.ajax.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._ERROR_HTTPERROR,
+                    myfaces._impl.core._jsfImpl._ERROR_HTTPERROR, "Request failed with status " + this.m_xhr.status
+                    + " and reason " + this.getHtmlStatusText());
+            }
+        }
 	} catch (e) {
-		this.m_exception.throwError("requestCallback", e);
+		this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
 	}
-};
+}
+
 /**
  * Spec. 13.3.1
  * Collect and encode input elements.
  * Additionally the hidden element javax.faces.ViewState
- * @param {String} FORM_ELEMENT - Client-Id of Form-Element
  * @return {String} - Concatenated String of the encoded input elements
  * 			and javax.faces.ViewState element
  */
-myfaces._impl.xhrCore._AjaxRequest.prototype.getViewState = function(FORM_ELEMENT) {
-    return this.m_ajaxUtil.processUserEntries(this.m_source, FORM_ELEMENT, this.m_partialIdsArray);
+myfaces._impl.xhrCore._AjaxRequest.prototype.getViewState = function() {
+    return this.m_ajaxUtil.processUserEntries(this.m_xhr, this.m_context, this.m_source,
+        this.m_sourceForm, this.m_partialIdsArray);
 }
-
-/**
- * @return {String} status text of request
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.getHtmlStatusText = function() {
-	return this.m_request.statusText;
-};
-
-/**
- * @return {boolean} true if ajax request successfull
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.isComplete = function() {
-	return (this.m_request.readyState == 4 && this.m_request.status == 200);
-};
-
-/**
- * @return {boolean} true if ajax request failed
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.isFailed = function() {
-	return (this.m_request.readyState == 4 && this.m_request.status != 200);
-};
-
-/**
- * @return {boolean} true while ajax request is running
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.isPending = function() {
-	return (this.m_request.readyState == 1);
-};
-
-myfaces._impl.xhrCore._AjaxRequest.prototype.getSourceItem = function() {
-	return this.m_sourceItem;
-};
-myfaces._impl.xhrCore._AjaxRequest.prototype.setSourceItem = function(sourceItem) {
-	this.m_sourceItem = sourceItem;
-};
-
-myfaces._impl.xhrCore._AjaxRequest.prototype.getContentType = function() {
-	return this.m_contentType;
-};
-myfaces._impl.xhrCore._AjaxRequest.prototype.setContentType = function(contentType) {
-	this.m_contentType = contentType;
-};
\ No newline at end of file

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js Mon Apr 20 07:13:20 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.4 $ $Date: 2009/04/12 05:41:47 $
+ * Version: $Revision: 1.6 $ $Date: 2009/04/18 17:19:12 $
  *
  */
 
@@ -26,8 +26,7 @@
  */
 myfaces._impl.xhrCore._AjaxRequestQueue = function() {
 	this.m_request = null;
-	this.m_queuedRequests = new Object();
-	this.m_requestPending = false;
+	this.m_queuedRequests = [];
 	this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequestQueue", "NONE");
 };
 
@@ -38,15 +37,14 @@
 
 /**
  * [STATIC]
- * Triggers callback methode of class Request as callback referencing
- * of an object is not possible
+ * provides api callback
  */
 myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback = function() {
 	if (myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request != null) {
-        jsf.ajax.response(myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.m_request, "dummy");
+        myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.requestCallback();
 	} else {
 		myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_exception.throwWarning
-			("doRequestCallback", "No request object available");
+			(null, null, "doRequestCallback", "No request object available");
 	}
 };
 
@@ -55,12 +53,13 @@
  * @param {myfaces._impl.xhrCore._AjaxRequest} request - request to send
  */
 myfaces._impl.xhrCore._AjaxRequestQueue.prototype.queueRequest = function(request) {
-	if (this.m_requestPending == false) {
-		this.m_requestPending = true;
+	if (this.m_request == null) {
 		this.m_request = request;
-		this.doRequest();
+		this.m_request.send();
 	} else {
-		this.m_queuedRequest = request;
+		this.m_queuedRequests.push(request);
+        if (request.m_queuesize > -1 && request.m_queuesize < this.m_queuedRequests.length)
+            this.m_queuedRequests.shift();
 	}
 };
 
@@ -68,24 +67,15 @@
  * process queue, send request, if exists
  */
 myfaces._impl.xhrCore._AjaxRequestQueue.prototype.processQueue = function() {
-	if (this.m_queuedRequest != null) {
-		this.m_request = this.m_queuedRequest;
-		this.m_queuedRequest = null;
-		this.doRequest();
-	} else {
-		this.m_requestPending = false;
-	}
-};
-
-/**
- * send ajax request
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.prototype.doRequest = function() {
-	if (this.m_request != null) {
-		this.m_request.send(this);
+	if (this.m_queuedRequests.length > 0) {
+        // Using Javascripts build-in queue capabilities here!
+        // JSF RI is using Delayed Shift Queue (DSQ), which starts to outperform the build-in queue
+        // when queue size exceeds ~10 requests (http://safalra.com/web-design/javascript/queues/).
+        // With JSF Ajax the queue will hardly ever reach this size.
+		this.m_request = this.m_queuedRequests.shift();
+		this.m_request.send();
 	} else {
-		this.m_exception.throwWarning("doRequest",
-				"No request object available");
+        this.m_request = null;
 	}
 };
 

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Mon Apr 20 07:13:20 2009
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- * Author: Ganesh Jung (latest modification by $Author: werpu $)
- * Version: $Revision: 1.12 $ $Date: 2009/04/17 13:46:02 $
+ * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
+ * Version: $Revision: 1.14 $ $Date: 2009/04/18 17:19:12 $
  *
  */
 
@@ -26,12 +26,8 @@
  * @param {String} alarmThreshold
  */
 myfaces._impl.xhrCore._AjaxResponse = function(alarmThreshold) {
-    // Request object
-    this.m_request = null;
-    // Html-Form-Element from which the request comes from
-    this.m_htmlFormElement = null;
-    this.alarmThreshold = alarmThreshold;
-    this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxResponse", this.alarmThreshold);
+	this.alarmThreshold = alarmThreshold;
+	this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxResponse", this.alarmThreshold);
 };
 
 /*partial response types*/
@@ -50,23 +46,8 @@
 myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_ATTRIBUTES  = "attributes";
 myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_EXTENSION   = "extension";
 
-/*various errors within the rendering stage*/
-myfaces._impl.xhrCore._AjaxResponse.prototype._ERROR_EMPTY_RESPONSE = "emptyResponse";
-myfaces._impl.xhrCore._AjaxResponse.prototype._ERROR_MALFORMEDXML   = "malformedXML";
-myfaces._impl.xhrCore._AjaxResponse.prototype._ERROR_SERVER_ERROR   = "serverError";
-myfaces._impl.xhrCore._AjaxResponse.prototype._MSG_SUCCESS          = "success";
-
-/*various ajax message types*/
-myfaces._impl.xhrCore._AjaxResponse.prototype._MSG_TYPE_ERROR       = "error";
-myfaces._impl.xhrCore._AjaxResponse.prototype._MSG_TYPE_EVENT       = "event";
-myfaces._impl.xhrCore._AjaxResponse.prototype._AJAX_STAGE_BEGIN     = "begin";
-myfaces._impl.xhrCore._AjaxResponse.prototype._AJAX_STAGE_COMPLETE  = "complete";
-myfaces._impl.xhrCore._AjaxResponse.prototype._AJAX_STAGE_HTTPERROR = "httpError";
-
 /**
  * uses response to start Html element replacement
- * @param {XmlHttpRequest} request - request object
- * @param {HtmlElement} sourceForm - HTML Form element which contains the element that triggered the request
  * @param {Map} context - AJAX context
  *
  * A special handling has to be added to the update cycle
@@ -75,10 +56,8 @@
  * and if the CDATA block contains a body section the document body must be replaced!
  *
  */
-myfaces._impl.xhrCore._AjaxResponse.prototype.processResponse = function(request, sourceForm, context) {
-    this.m_request = request;
-    this.m_htmlFormElement = sourceForm;
-    try {
+myfaces._impl.xhrCore._AjaxResponse.prototype.processResponse = function(request, context) {
+	try {
         // TODO:
         // Solution from
         // http://www.codingforums.com/archive/index.php/t-47018.html
@@ -89,19 +68,19 @@
         }
 
         if (!myfaces._impl._util._LangUtils.exists(request, "responseXML")) {
-            jsf.ajax.sendError(request, context, this._ERROR_EMPTY_RESPONSE);
+            jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE);
             return;
         }
 
         var xmlContent = request.responseXML;
         if (xmlContent.firstChild.tagName == "parsererror") {
-            jsf.ajax.sendError(request, context, this._ERROR_MALFORMEDXML);
+            jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
             return;
         }
         var partials = xmlContent.childNodes[0];
         if ('undefined' == typeof partials || partials == null
             || partials.tagName != this._RESPONSE_PARTIAL) {
-            jsf.ajax.sendError(request, context, this._ERROR_MALFORMEDXML);
+            jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
             return;
         }
 
@@ -143,7 +122,7 @@
                     errorMessage = "";
                 }
 
-                jsf.ajax.sendError(request, context,this._ERROR_SERVER_ERROR , errorName, errorMessage);
+                jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR , errorName, errorMessage);
 
                 return;
                 
@@ -154,7 +133,7 @@
                  */
                 var redirectUrl = childNode.getAttribute("url");
                 if('undefined' == typeof redirectUrl || null == redirectUrl) {
-                    jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML,this._ERROR_MALFORMEDXML,"Redirect without url");
+                    jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,"Redirect without url");
                     return;
                 }
                 redirectUrl = myfaces._impl._util._LangUtils.trim(redirectUrl);
@@ -176,9 +155,7 @@
                         //if present then set them if the form has no element of type javax.faces.viewState
                         //append a hidden field and set it!
 
-
-
-                        } else {
+                      } else {
                             //TODO make a special head body and html handling here
                             var cDataBlock = changes[i].firstChild.data;
                             if( changes[i].getAttribute('id') == "javax.faces.ViewRoot") {
@@ -199,7 +176,7 @@
                                     //lets have the browser itself deal with this issue, j4fry
                                     //is pretty well optimized in this area!
                                     if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
-                                        myfaces._impl._util._Utils.runScripts(head);
+                                        myfaces._impl._util._Utils.runScripts(request, context, head);
                                     }
                                 }
 
@@ -211,17 +188,17 @@
                                     //TODO fetch the scripts and do an eval on the scripts to bypass
                                     //browser inconsistencies in this area
                                     if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
-                                        myfaces._impl._util._Utils.runScripts(head);
+                                        myfaces._impl._util._Utils.runScripts(request, context, head);
                                     }
                                 //no body content is defined means we have to replace the body with the entire cdata content
                                 } else {
                                     body = cDataBlock;
                                     if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
-                                        myfaces._impl._util._Utils.runScripts(head);
+                                        myfaces._impl._util._Utils.runScripts(request, context, head);
                                     }
                                 }
                             } else {
-                                myfaces._impl._util._Utils.replaceHtmlItem(
+                                myfaces._impl._util._Utils.replaceHtmlItem(request, context,
                                     changes[i].getAttribute('id'), cDataBlock, this.m_htmlFormElement);
                             }
                         }
@@ -248,11 +225,11 @@
                         var afterSet    = 'undefined' != typeof afterId && null != afterId && myfaces._impl._util._LangUtils.trim(afterId) != "";
 
                         if(!insertSet) {
-                            jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML,this._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
+                            jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
                             return;
                         }
                         if(!(beforeSet || afterSet)) {
-                            jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML, this._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
+                            jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
                             return;
                         }
                         //either before or after but not two at the same time
@@ -260,7 +237,7 @@
                             beforeId = myfaces._impl._util._LangUtils.trim(beforeId);
                             var beforeNode = document.getElementById(beforeId);
                             if('undefined' == typeof beforeNode || null == beforeNode) {
-                                jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML, this._ERROR_MALFORMEDXML, "Error in PPR Insert, before  node of id "+beforeId+" does not exist in document");
+                                jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before  node of id "+beforeId+" does not exist in document");
                                 return;
                             }
                             /**
@@ -274,21 +251,21 @@
                             var parentNode = beforeNode.parentNode;
                             parentNode.insertBefore(nodeHolder, beforeNode);
 
-                            myfaces._impl._util._Utils.replaceHtmlItem(
+                            myfaces._impl._util._Utils.replaceHtmlItem(request, context,
                                     nodeHolder, changes[i].firstChild.data, null);
 
                         } else {
                             afterId = myfaces._impl._util._LangUtils.trim(afterId);
                             var afterNode = document.getElementById(afterId);
                             if('undefined' == typeof afterNode || null == afterNode) {
-                                jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML,this._ERROR_MALFORMEDXML, "Error in PPR Insert, after  node of id "+after+" does not exist in document");
+                                jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, after  node of id "+after+" does not exist in document");
                                 return;
                             }
                             var nodeHolder = document.createElement("div");
                             //nodeHolder.innerHTML = changes[i].firstChild.data;
                             var parentNode = afterNode.parentNode;
                             parentNode.insertBefore(nodeHolder, afterNode.nextSibling);
-                            myfaces._impl._util._Utils.replaceHtmlItem(
+                            myfaces._impl._util._Utils.replaceHtmlItem(request, context, 
                                     nodeHolder, changes[i].firstChild.data, null);
                         }
 
@@ -296,11 +273,11 @@
                         // this._responseHandler.doDelete(childNode);
                         var deleteId = changes[i].getAttribute('id');
                         if('undefined' == typeof deleteId || null == deleteId) {
-                            jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML,this._ERROR_MALFORMEDXML,  "Error in delete, id not in xml markup");
+                            jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,  "Error in delete, id not in xml markup");
                             return;
                         }
 
-                        myfaces._impl._util._Utils.deleteItem(deleteId, "","");
+                        myfaces._impl._util._Utils.deleteItem(request, context, deleteId, "","");
 
                     } else if (changes[i].tagName == this._PCMD_ATTRIBUTES) {
                         //we now route into our attributes function to bypass
@@ -313,7 +290,7 @@
                         var attributesRoot = changes[i];
                         var elementId = attributesRoot.getAttribute('id');
                         if('undefined' == typeof elementId || null == elementId) {
-                            jsf.ajax.sendError(request, context,this._ERROR_MALFORMEDXML,this._ERROR_MALFORMEDXML,  "Error in attributes, id not in xml markup");
+                            jsf.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,  "Error in attributes, id not in xml markup");
                             return;
                         }
                         var childs = attributesRoot.childNodes;
@@ -346,15 +323,14 @@
                     //  this._responseHandler.doExtension(childNode);
 
                     } else {
-                        jsf.ajax.sendError(request, context, this._ERROR_MALFORMEDXML);
+                        jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
                         return;
                     }
 
                 }
             } 
         }
-        jsf.ajax.sendEvent(request, context, this._MSG_SUCCESS);
     } catch (e) {
-        this.m_exception.throwError("processResponse", e);
+        this.m_exception.throwError(request, context, "processResponse", e);
     }
 };

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Mon Apr 20 07:13:20 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.4 $ $Date: 2009/04/12 06:18:13 $
+ * Version: $Revision: 1.6 $ $Date: 2009/04/19 06:46:13 $
  *
  */
 
@@ -28,7 +28,6 @@
 myfaces._impl.xhrCore._AjaxUtils = function(alarmThreshold) {
 	// Exception Objekt
 	this.alarmThreshold = alarmThreshold;
-	this.PARTIAL_PREFIX = "_j4fry_partial_submit_";
 	this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxUtils", this.alarmThreshold);
 };
 
@@ -38,13 +37,13 @@
  * @param {HtmlElement} parentItem - form element item is nested in
  * @param {Array} partialIds - ids fo PPS
  */
-myfaces._impl.xhrCore._AjaxUtils.prototype.processUserEntries = function(item,
+myfaces._impl.xhrCore._AjaxUtils.prototype.processUserEntries = function(request, context, item,
 		parentItem,	partialIds) {
 	try {
 		var form = parentItem;
 
 		if (form == null) {
-			this.m_exception.throwWarning("processUserEntries",
+			this.m_exception.throwWarning(request, context, "processUserEntries",
 					"Html-Component is not nested in a Form-Tag");
 			return null;
 		}
@@ -73,7 +72,7 @@
 		return stringBuffer.join("");
 	} catch (e) {
 		alert(e);
-		this.m_exception.throwError("processUserEntries", e);
+		this.m_exception.throwError(request, context, "processUserEntries", e);
 	}
 };
 
@@ -82,8 +81,6 @@
  * @param {} node - 
  * @param {} insideSubmittedPart -
  * @param {} partialIds -
- * @param {} disableFlag -
- * @param {} disableTypesArr -
  * @param {} stringBuffer -
  */
 myfaces._impl.xhrCore._AjaxUtils.prototype.addNodes = function(node, insideSubmittedPart,
@@ -96,19 +93,12 @@
 			var elementName = child.name;
 			if (child.nodeType == 1) {
 				var isPartialSubmitContainer = ((id != null) 
-                    && myfaces._impl._util._LangUtils.arrayContains(partialIds, 
-                        myfaces._impl._util._LangUtils.splitAndGetLast(id, ":")));
+                    && myfaces._impl._util._LangUtils.arrayContains(partialIds, id));
 				if (insideSubmittedPart
 						|| isPartialSubmitContainer
 						|| (elementName != null 
-                        && myfaces._impl._util._LangUtils.arrayContains(jsfKeywords, elementName))) {
-					// send id for PPS if uppermost submitted container
-					if (isPartialSubmitContainer) {
-						stringBuffer[stringBuffer.length] = this.PARTIAL_PREFIX;
-						stringBuffer[stringBuffer.length] = encodeURIComponent(id);
-						stringBuffer[stringBuffer.length] = "=&";
-					}
-					// node required fpr PPS
+                        && elementName == myfaces._impl.core._jsfImpl._PROP_VIEWSTATE)) {
+					// node required for PPS
 					this.addField(child, stringBuffer);
 					if (insideSubmittedPart || isPartialSubmitContainer) {
 						// check for further children

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js Mon Apr 20 07:13:20 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.3 $ $Date: 2009/04/12 05:41:47 $
+ * Version: $Revision: 1.4 $ $Date: 2009/04/18 17:19:12 $
  *
  */
 
@@ -30,26 +30,27 @@
  * [STATIC]
  * static method used by static methods that throw errors
  */
-myfaces._impl.xhrCore._Exception.throwNewError = function(sourceClass, func, exception) {
-	newException = new myfaces._impl.xhrCore._Exception(sourceClass, "ERROR");
-	newException.throwError(func, exception);
+myfaces._impl.xhrCore._Exception.throwNewError = function(request, context, sourceClass, func, exception) {
+	newException = new myfaces._impl.xhrCore._Exception(request, context, sourceClass, "ERROR");
+	newException.throwError(request, context, func, exception);
 };
 
 /**
  * [STATIC]
  * static method used by static methods that throw warnings
  */
-myfaces._impl.xhrCore._Exception.throwNewWarning = function(sourceClass, func, message){
-	newException = new myfaces._impl.xhrCore._Exception(sourceClass, "WARNING");
-	newException.throwWarning(func, message);
+myfaces._impl.xhrCore._Exception.throwNewWarning = function(request, context, sourceClass, func, message){
+	newException = new myfaces._impl.xhrCore._Exception(request, context, sourceClass, "WARNING");
+	newException.throwWarning(request, context, func, message);
 };
 
 /**
  * throws errors
  */
-myfaces._impl.xhrCore._Exception.prototype.throwError = function(func, exception) {
+myfaces._impl.xhrCore._Exception.prototype.throwError = function(request, context, func, exception) {
 	if (this.m_threshold == "ERROR") {
-		alert("[MyFaces ERROR]\n\n"
+		jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, exception.name,
+                "MyFaces ERROR\n"
 				+ "Affected Class: " + this.m_class + "\n"
 				+ "Affected Method: " + func + "\n"
 				+ "Error name: " + exception.name + "\n"
@@ -64,9 +65,10 @@
 /**
  * throws warnings
  */
-myfaces._impl.xhrCore._Exception.prototype.throwWarning = function(func, message) {
+myfaces._impl.xhrCore._Exception.prototype.throwWarning = function(request, context, func, message) {
 	if (this.m_threshold == "WARNING" || this.m_threshold == "ERROR") {
-		alert("[MyFaces WARNING]\n[" + this.m_class + "::" + func + "]\n\n"
+		jsf.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, exception.name,
+            "MyFaces WARNING\n[" + this.m_class + "::" + func + "]\n\n"
 				+ message);
 	}
 	this.destroy();

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js Mon Apr 20 07:13:20 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.6 $ $Date: 2009/04/13 19:50:24 $
+ * Version: $Revision: 1.8 $ $Date: 2009/04/19 06:46:13 $
  *
  */
 
@@ -26,12 +26,6 @@
 myfaces._impl.xhrCore._Ajax = function() {}
 
 /**
- * [STATIC PROPERTIES]
- */
-// request, type myfaces._impl.xhrCore._AjaxRequest
-myfaces._impl.xhrCore._Ajax.request = null;
-
-/**
  * Spec. 13.3.1
  * Collect and encode input elements.
  * Additinoaly the hidden element javax.faces.ViewState
@@ -40,7 +34,7 @@
  * 			and javax.faces.ViewState element
  */
 myfaces._impl.xhrCore._Ajax.prototype.getViewState = function(FORM_ELEMENT) {
-    return myfaces._impl.xhrCore._Ajax.request.getViewState(FORM_ELEMENT);
+    return myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.getViewState();
 }
 
 
@@ -48,85 +42,19 @@
  * mapped options already have the exec and view properly in place
  * myfaces specifics can be found under mappedOptions.myFaces
  * @param ajaxContext the ajax context which also has to be pushed into the messages and into the response
-
-        var ajaxContext = {};
-        ajaxContext.source = element;
-        ajaxContext.onevent = options.onevent;
-        ajaxContext.onerror = options.onerror;
-
-       action the action to be used in the xhr request
-
  **/
 
 myfaces._impl.xhrCore._Ajax.prototype._ajaxRequest = function(source, sourceForm, context, passThroughValues ) {
-    myfaces._impl.xhrCore._Ajax.request = new myfaces._impl.xhrCore._AjaxRequest(source, sourceForm, context, passThroughValues);
-   	myfaces._impl.xhrCore._AjaxRequestQueue.queue.queueRequest(myfaces._impl.xhrCore._Ajax.request.prepare());
+   	myfaces._impl.xhrCore._AjaxRequestQueue.queue.queueRequest(
+        new myfaces._impl.xhrCore._AjaxRequest(source, sourceForm, context, passThroughValues));
 }
 
 /**
- *this has to be called by from various stages of the lifecycle
- *we probably can move this method one level up
- *
- *The idea of this method is following:
- *jsf needs event callback from various stages of the client side lifecycle
- *either errors or events
- *
- *when those events are dispatched in the lifecycle and when the response handling
- *is called is handled here!
- */
-myfaces._impl.xhrCore._Ajax._xhrEventDispatcher = function(context, request) {
-
-        var READY_STATE_UNSENT = 0;
-        var READY_STATE_OPENED = 1;
-        var READY_STATE_HEADERS_RECEIVED = 2;
-        var READY_STATE_LOADING = 3;
-        var READY_STATE_DONE = 4;
-
-        
-   
-        var complete = false;
-        /*here we have to do the event mapping back into the ri events*/
-
-        //onEvent and onError are served on the JSF side as well!
-
-
-        switch(request.readyState) {
-            case xhrConst.READY_STATE_OPENED:
-                jsf.ajax.sendEvent(null, context, "begin");
-                break;
-            case READY_STATE_DONE:
-                /**
-                  *here we can do our needed callbacks so
-                  *that the specification is satisfied
-                  **/
-                complete = true;
-
-                var responseStatusCode = request.status;
-
-                if(200 <= responseStatusCode && 300 > responseStatusCode ) {
-                    jsf.ajax.sendEvent(request, context, "complete");
-
-                    jsf.ajax.response(request, context);
-                } else {
-                    jsf.ajax.sendEvent(request, context, "complete");
-                    jsf.ajax.sendError(request, context, "httpError");
-                }
-                break;
-            default:
-                break;
-        }
-        return complete;
-    };
-
-/**
  * Spec. 13.3.3
  * Examining the response markup and updating the DOM tree
- * @param {XmlHttpRequest} request - The Ajax Request
- * @param {XmlHttpRequest} context - The Ajax context
+ * @param {XmlHttpRequest} request - the ajax request
+ * @param {XmlHttpRequest} context - the ajax context
  */
 myfaces._impl.xhrCore._Ajax.prototype._ajaxResponse = function(request, context) {
-	if(myfaces._impl.xhrCore._Ajax.request == null)
-		alert("Cannot process ajax response because there's no ajax request.");
-	myfaces._impl.xhrCore._Ajax.request.requestCallback();
-   	myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
+	myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.m_response.processResponse(request, context);
 }

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js?rev=766601&r1=766600&r2=766601&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js Mon Apr 20 07:13:20 2009
@@ -109,7 +109,7 @@
      * TODO make sure this method also occurrs in the specs
      * otherwise simply pull it
      */
-    jsf.ajax.sendEvent = function sendEvent(/*Object*/request, /*Object*/ context, /*even name*/ name) {
+    jsf.ajax.sendEvent = function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
         jsf.ajax._impl.sendEvent(request, context, name);
     }