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/21 12:51:21 UTC

svn commit: r946969 [3/3] - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces: _impl/_util/ _impl/core/ _impl/xhrCore/ api/

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js Fri May 21 10:51:20 2010
@@ -33,6 +33,7 @@
  *
  * or transport.xhrPost,transport.xhrGet  etc... in the future
  */
+/** @namespace myfaces._impl.xhrCore._Transports */
 myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._Transports"
         , Object, {
 
@@ -55,7 +56,7 @@ myfaces._impl.core._Runtime.extendClass(
      * (This is the same limitation dojo class inheritance
      * where our inheritance pattern is derived from has)
      */
-    _queue: new myfaces._impl.xhrCore._AjaxRequestQueue(),
+    _q: new myfaces._impl.xhrCore._AjaxRequestQueue(),
 
     _threshold: "ERROR",
 
@@ -68,11 +69,11 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {Node} source the source of this call
      * @param {Node} sourceForm the html form which is the source of this call
      * @param {Object} context (Map) the internal pass through context
-     * @param {Object} passThroughValues (Map) values to be passed through
+     * @param {Object} passThrgh (Map) values to be passed through
      **/
-    xhrQueuedPost : function(source, sourceForm, context, passThroughValues) {
-        this._queue.queueRequest(
-                new myfaces._impl.xhrCore._AjaxRequest(this._getArguments(source, sourceForm, context, passThroughValues)));
+    xhrQueuedPost : function(source, sourceForm, context, passThrgh) {
+        this._q.enqueue(
+                new myfaces._impl.xhrCore._AjaxRequest(this._getArguments(source, sourceForm, context, passThrgh)));
     },
 
     /**
@@ -82,7 +83,7 @@ myfaces._impl.core._Runtime.extendClass(
      * @param {XmlHttpRequest} context - the ajax context
      */
     response : function(request, context) {
-        this._queue._curReq._response.processResponse(request, context);
+        this._q._curReq._response.processResponse(request, context);
     },
 
     /**
@@ -93,18 +94,19 @@ myfaces._impl.core._Runtime.extendClass(
      * @param source the source of the request
      * @param sourceForm the sourceform
      * @param context   the context holding all values
-     * @param passThroughValues the passThrough values to be blended into the response
+     * @param passThrgh the passThrough values to be blended into the response
      */
-    _getArguments: function(source, sourceForm, context, passThroughValues) {
-        var _Runtime = myfaces._impl.core._Runtime;
-        var _getConfig = _Runtime.getLocalOrGlobalConfig;
+    _getArguments: function(source, sourceForm, context, passThrgh) {
+        var _RT = myfaces._impl.core._Runtime;
+        var _getConfig = _RT.getLocalOrGlobalConfig;
+        var _Lang = myfaces._impl._util._Lang;
 
-        var arguments = {
+        var ret = {
             "source": source,
             "sourceForm": sourceForm,
             "context": context,
-            "passThrough": passThroughValues,
-            "xhrQueue": this._queue,
+            "passThrough": passThrgh,
+            "xhrQueue": this._q,
 
             //standard done callback
             "onDone": this._Lang.hitch(this, this._stdOnDone),
@@ -123,19 +125,19 @@ myfaces._impl.core._Runtime.extendClass(
 
         //we now mix in the config settings which might either be set globally
         //or pushed in under the context myfaces.<contextValue> into the current request 
-        this._applyConfig(arguments, "alarmThreshold", this._PAR_ERRORLEVEL);
-        this._applyConfig(arguments, "queueSize", this._PAR_QUEUESIZE);
-        this._applyConfig(arguments, "timeout", this._PAR_TIMEOUT);
-        this._applyConfig(arguments, "delay", this._PAR_DELAY);
+        this._applyConfig(ret, "alarmThreshold", this._PAR_ERRORLEVEL);
+        this._applyConfig(ret, "queueSize", this._PAR_QUEUESIZE);
+        this._applyConfig(ret, "timeout", this._PAR_TIMEOUT);
+        this._applyConfig(ret, "delay", this._PAR_DELAY);
 
         //now partial page submit needs a different treatment
         //since pps == execute strings
         if (_getConfig(context, this._PAR_PPS, null) != null
-                && _Lang.exists(passThrough, myfaces._impl.core.Impl._PROP_EXECUTE)
-                && passThrough[myfaces._impl.core.Impl._PROP_EXECUTE].length > 0) {
-            arguments['partialIdsArray'] = passThrough[myfaces._impl.core.Impl._PROP_EXECUTE].split(" ");
+                && _Lang.exists(passThrgh, myfaces._impl.core.Impl.P_EXECUTE)
+                && passThrgh[myfaces._impl.core.Impl.P_EXECUTE].length > 0) {
+            ret['partialIdsArray'] = passThrgh[myfaces._impl.core.Impl.P_EXECUTE].split(" ");
         }
-        return arguments;
+        return ret;
     },
 
     /**
@@ -146,8 +148,8 @@ myfaces._impl.core._Runtime.extendClass(
      * @param srcParm the source param which is the key to our config setting
      */
     _applyConfig: function(destination, destParm, srcParm) {
-        var _Runtime = myfaces._impl.core._Runtime;
-        var _getConfig = _Runtime.getLocalOrGlobalConfig;
+        var _RT = myfaces._impl.core._Runtime;
+        var _getConfig = _RT.getLocalOrGlobalConfig;
         if (_getConfig(this._context, srcParm, null) != null) {
             destination[destParm] = _getConfig(this._context, srcParm, null);
         }
@@ -163,7 +165,7 @@ myfaces._impl.core._Runtime.extendClass(
     _stdOnDone: function(request, context) {
         this._loadImpl();
 
-        this._Impl.sendEvent(request, context, this._Impl._AJAX_STAGE_COMPLETE);
+        this._Impl.sendEvent(request, context, this._Impl.COMPLETE);
     },
 
     /**
@@ -177,8 +179,8 @@ myfaces._impl.core._Runtime.extendClass(
         this._loadImpl();
 
         this._Impl.response(request, context);
-        this._Impl.sendEvent(request, context, this._Impl._AJAX_STAGE_SUCCESS);
-        this._queue.processQueue();
+        this._Impl.sendEvent(request, context, this._Impl.SUCCESS);
+        this._q.processQueue();
 
     },
 
@@ -206,23 +208,17 @@ myfaces._impl.core._Runtime.extendClass(
             errorText = "Request failed with unknown status";
         }
         //_onError
-        this._Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_HTTPERROR,
-                myfaces._impl.core.Impl._ERROR_HTTPERROR, errorText);
+        this._Impl.sendError(request, context, this._Impl.HTTPERROR,
+                this._Impl.HTTPERROR, errorText);
     },
 
 
 
     /**
      * standard timeout handler
-     *
-     * @param request the xhr request object
-     * @param context the context holding all values for further processing
      */
-    _stdOnTimeout: function(request, context) {
-        var timeoutFunc = _Lang.hitch(this,
-                function() {
-                    this._queue._curReq.abort();
-                });
+    _stdOnTimeout: function() {
+        this._q._curReq.abort();
     },
 
     /**
@@ -239,13 +235,14 @@ myfaces._impl.core._Runtime.extendClass(
     _stdErrorHandler: function(request, context, sourceClass, func, exception) {
         this._loadImpl();
         
-        if (this._threshold == "ERROR") {
-            this._Impl.sendError(request, context, this._Impl._ERROR_CLIENT_ERROR, exception.name,
-                    "MyFaces ERROR:" + this._Lang.createErrorMessage(sourceClass, func, exception));
+        if (this._threshold == "ERROR" && !exception._processed) {
+            this._Impl.sendError(request, context, this._Impl.CLIENT_ERROR, exception.name,
+                    "MyFaces ERROR:" + this._Lang.createErrorMsg(sourceClass, func, exception));
         }
-        this._queue.cleanup();
+        this._q.cleanup();
         //we forward the exception, just in case so that the client
         //will receive it in any way
+        exception._processed = true;
         throw exception;
     },
 
@@ -262,8 +259,8 @@ myfaces._impl.core._Runtime.extendClass(
         this._loadImpl();
 
         if (this._threshold == "WARNING" || this._threshold == "ERROR") {
-            this._Impl.sendError(request, context, this._Impl._ERROR_CLIENT_ERROR, exception.name,
-                    "MyFaces WARNING:" + this._Lang.createErrorMessage(sourceClass, func, exception));
+            this._Impl.sendError(request, context, this._Impl.CLIENT_ERROR, exception.name,
+                    "MyFaces WARNING:" + this._Lang.createErrorMsg(sourceClass, func, exception));
         }
         this.destroy();
     },

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js Fri May 21 10:51:20 2010
@@ -29,48 +29,49 @@ if ('undefined' != typeof OpenAjax && ('
 }
 //just in case openajax has failed (testing environment)
 //under normal circumstances this should not happen
-if ('undefined' == typeof jsf || null == jsf) {
-    jsf = new Object();
-
-    /*
-     * specified by the spec symbols/jsf.html#.specversion
-     * as specified left two digits major release number
-     * middle two digits minor spec release number
-     * right two digits bug release number
-     */
-    jsf.specversion = 200000;
-    /**
-     * specified by the spec symbols/jsf.html#.implversion
-     * a number increased with every implementation version
-     * and reset by moving to a new spec release number
-     *
-     * Due to the constraints that we cannot put
-     * non jsf.&lt;namespace&gt; references outside of functions in the api
-     * we have to set the version here instead of the impl.
-     */
-    jsf.implversion = 0;
-
-    /**
-     * @return the current project state emitted by the server side method:
-     * javax.faces.application.Application.getProjectStage()
-     */
-    jsf.getProjectStage = function() {
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.getProjectStage();
-    };
-
-    /**
-     * 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!
-     * return a concatenated string of the encoded values!
-     *
-     * @throws an exception in case of the given element not being of type form!
-     * https://issues.apache.org/jira/browse/MYFACES-2110
-     */
-    jsf.getViewState = function(formElement) {
-        /*we are not allowed to add the impl on a global scope so we have to inline the code*/
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.getViewState(formElement);
+//either check for window.jsf == true or do it the verbose way
+if (!window.jsf) {
+    window.jsf = new function() {
+        /*
+         * specified by the spec symbols/jsf.html#.specversion
+         * as specified left two digits major release number
+         * middle two digits minor spec release number
+         * right two digits bug release number
+         */
+        this.specversion = 200000;
+        /**
+         * specified by the spec symbols/jsf.html#.implversion
+         * a number increased with every implementation version
+         * and reset by moving to a new spec release number
+         *
+         * Due to the constraints that we cannot put
+         * non jsf.&lt;namespace&gt; references outside of functions in the api
+         * we have to set the version here instead of the impl.
+         */
+        this.implversion = 0;
+
+        /**
+         * @return the current project state emitted by the server side method:
+         * javax.faces.application.Application.getProjectStage()
+         */
+        this.getProjectStage = function() {
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.getProjectStage();
+        };
+
+        /**
+         * 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!
+         * return a concatenated string of the encoded values!
+         *
+         * @throws an exception in case of the given element not being of type form!
+         * https://issues.apache.org/jira/browse/MYFACES-2110
+         */
+        this.getViewState = function(formElement) {
+            /*we are not allowed to add the impl on a global scope so we have to inline the code*/
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.getViewState(formElement);
+        };
     };
 }
 
@@ -80,71 +81,73 @@ if ('undefined' == typeof jsf || null ==
  * by overriding null or fiddeling around with undefined or typeof in some ways
  * it is safer in this case than the standard way of doing a strong comparison
  **/
-if ('undefined' == typeof jsf.ajax || null == jsf.ajax) {
-    jsf.ajax = new Object();
+if (!jsf.ajax) {
+    jsf.ajax = new function() {
 
 
-    /**
-     * this function has to send the ajax requests
-     *
-     * following request conditions must be met:
-     * <ul>
-     *  <li> the request must be sent asynchronously! </li>
-     *  <li> the request must be a POST!!! request </li>
-     *  <li> the request url must be the form action attribute </li>
-     *  <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
-     * </ul>
-     *
-     * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted
-     * @param {|EVENT|} event: any javascript event supported by that object
-     * @param {Map||} options : map of options being pushed into the ajax cycle
-     */
-    jsf.ajax.request = function(element, event, options) {
-	if (!options) {
-		options = {};
-	}
-        /*we are not allowed to add the impl on a global scope so we have to inline the code*/
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.request(element, event, options);
-    };
-
-    jsf.ajax.addOnError = function(/*function*/errorListener) {
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.addOnError(errorListener);
+        /**
+         * this function has to send the ajax requests
+         *
+         * following request conditions must be met:
+         * <ul>
+         *  <li> the request must be sent asynchronously! </li>
+         *  <li> the request must be a POST!!! request </li>
+         *  <li> the request url must be the form action attribute </li>
+         *  <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
+         * </ul>
+         *
+         * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted
+         * @param {|EVENT|} event: any javascript event supported by that object
+         * @param {Map||} options : map of options being pushed into the ajax cycle
+         */
+        this.request = function(element, event, options) {
+            if (!options) {
+                options = {};
+            }
+            /*we are not allowed to add the impl on a global scope so we have to inline the code*/
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.request(element, event, options);
+        };
+
+        this.addOnError = function(/*function*/errorListener) {
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.addOnError(errorListener);
+        };
+
+        this.addOnEvent = function(/*function*/eventListener) {
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.addOnEvent(eventListener);
+        };
+
+        /**
+         * processes the ajax response if the ajax request completes successfully
+         * @param request the ajax request!
+         * @param context the ajax context!
+         */
+        this.response = function(/*xhr request object*/request, context) {
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.response(request, context);
+        };
     }
-
-    jsf.ajax.addOnEvent = function(/*function*/eventListener) {
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.addOnEvent(eventListener);
-    }
-
-    /**
-     * processes the ajax response if the ajax request completes successfully
-     * @param request the ajax request!
-     * @param context the ajax context!
-     */
-    jsf.ajax.response = function(/*xhr request object*/request, context) {
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.response(request, context);
-    };
 }
 
-if ('undefined' == typeof jsf.util || null == jsf.util) {
-    jsf.util = new Object();
+if (!jsf.util) {
+    jsf.util = new function() {
 
-    /**
-     * varargs function which executes a chain of code (functions or any other code)
-     *
-     * if any of the code returns false, the execution
-     * is terminated prematurely skipping the rest of the code!
-     *
-     * @param {DomNode} source, the callee object
-     * @param {Event} event, the event object of the callee event triggering this function
-     *
-     */
-    jsf.util.chain = function(source, event) {
-        var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-        return impl.chain.apply(jsf.ajax._impl, arguments);
+        /**
+         * varargs function which executes a chain of code (functions or any other code)
+         *
+         * if any of the code returns false, the execution
+         * is terminated prematurely skipping the rest of the code!
+         *
+         * @param {DomNode} source, the callee object
+         * @param {Event} event, the event object of the callee event triggering this function
+         *
+         */
+        this.chain = function(source, event) {
+            var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+            return impl.chain.apply(jsf.ajax._impl, arguments);
+        };
     }
 }