You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2011/09/29 11:43:21 UTC

svn commit: r1177241 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_ExtLang.js _util/_Lang.js core/Impl.js xhrCore/_AjaxRequest.js xhrCore/_AjaxUtils.js

Author: werpu
Date: Thu Sep 29 09:43:21 2011
New Revision: 1177241

URL: http://svn.apache.org/viewvc?rev=1177241&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-3338
https://issues.apache.org/jira/browse/MYFACES-3334
https://issues.apache.org/jira/browse/MYFACES-3335

overhaul of the getViewState calling parts of the ajax subsystem
so that getViewState is called instead of our internal routines.



Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.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

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js?rev=1177241&r1=1177240&r2=1177241&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js Thu Sep 29 09:43:21 2011
@@ -73,7 +73,7 @@ myfaces._impl.core._Runtime.singletonDel
      */
     _log: function(logType /*+arguments*/, args) {
 
-        var argsString = this.objToArray(arguments[1]).join(" ");
+        var argsString = this.objToArray(arguments[1]).join("|");
         var c = window.console;
         
 
@@ -96,7 +96,15 @@ myfaces._impl.core._Runtime.singletonDel
                 elem.className ="consoleLog " + logType;
             }
             logHolder.appendChild(elem);
-            elem.innerHTML = logType.toUpperCase() + ": " + argsString;
+            var argsArr = this.objToArray(arguments[1]);
+            var argsStr = [];
+
+            for(var cnt = 0; cnt < argsArr.length; cnt++) {
+                argsStr.push("<div class='args args_"+cnt+"'>");
+                argsStr.push(argsArr[cnt]);
+                argsStr.push("</div>");
+            }
+            elem.innerHTML = "<div class='args argsinfo'>"+logType.toUpperCase() + "</div>" + argsStr.join("");
         }
     },
 

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=1177241&r1=1177240&r2=1177241&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js Thu Sep 29 09:43:21 2011
@@ -802,6 +802,30 @@ var _Lang = myfaces._impl.core._Runtime.
             };
 
         }
+        if (!this.FormDataDecoratorString) {
+            this.FormDataDecoratorString = function (theFormData) {
+                this._preprocessedData = theFormData;
+                this._valBuf = [];
+                this._idx = {};
+
+            };
+            _newCls = this.FormDataDecoratorString;
+            _newCls.prototype.append = function(key, val) {
+                this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)].join("="));
+                this._idx[key] = true;
+            };
+            //for now we check only for keys which are added subsequently otherwise we do not perform any checks
+            _newCls.prototype.hasKey = function(key) {
+                return !!this._idx[key];
+            };
+            _newCls.prototype.makeFinal = function() {
+                if(this._preprocessedData != "") {
+                  return this._preprocessedData + "&"+ this._valBuf.join("&")
+                } else {
+                  return this._valBuf.join("&");
+                }
+            };
+        }
         if (!this.FormDataDecoratorOther) {
             this.FormDataDecoratorOther = function (theFormData) {
                 this._valBuf = theFormData;
@@ -822,6 +846,8 @@ var _Lang = myfaces._impl.core._Runtime.
 
         if (formData instanceof Array) {
             bufInstance = new this.FormDataDecoratorArray(formData);
+        } else if(this.isString(formData)) {
+            bufInstance = new this.FormDataDecoratorString(formData);
         } else {
             bufInstance = new this.FormDataDecoratorOther(formData);
         }

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=1177241&r1=1177240&r2=1177241&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js Thu Sep 29 09:43:21 2011
@@ -109,10 +109,11 @@ myfaces._impl.core._Runtime.singletonExt
             throw new Error(this._Lang.getMessage("ERR_VIEWSTATE"));
         }
 
-        var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
+        var ajaxUtils = myfaces._impl.xhrCore._AjaxUtils;
 
         var ret = this._Lang.createFormDataDecorator([]);
-        ajaxUtils.encodeSubmittableFields(ret, null, null, null, form, null);
+        ajaxUtils.encodeSubmittableFields(ret,  form, null);
+
         return ret.makeFinal();
     },
 

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=1177241&r1=1177240&r2=1177241&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 Thu Sep 29 09:43:21 2011
@@ -288,10 +288,25 @@ myfaces._impl.core._Runtime.extendClass(
              */
             getFormData : function() {
 
-                var ret = this._Lang.createFormDataDecorator(new Array());
+                var ret = null;
 
-                this._AJAXUTIL.encodeSubmittableFields(ret, this._xhr, this._context, this._source,
-                        this._sourceForm, this._partialIdsArray);
+                //now this is less performant but we have to call it to allow viewstate decoration
+                if(!this._partialIdsArray || !this._partialIdsArray.length) {
+                    var viewState = jsf.getViewState(this._sourceForm);
+                    ret = this._Lang.createFormDataDecorator(viewState);
+
+                    //just in case the source item is outside of the form
+                    //only if the form override is set we have to append the issuing item
+                    //otherwise it is an element of the parent form
+                    if(this._source && this._context.myfaces && this._context.myfaces.form)
+                        this._AJAXUTIL.appendIssuingItem(this._source);
+                } else {
+                    ret = this._Lang.createFormDataDecorator(new Array());
+                    this._AJAXUTIL.encodeSubmittableFields(ret,
+                            this._sourceForm, this._partialIdsArray);
+                    if(this._source && this._context.myfaces && this._context.myfaces.form)
+                        this._AJAXUTIL.appendIssuingItem(this._source);
+                }
 
                 return ret;
             },

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=1177241&r1=1177240&r2=1177241&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 Thu Sep 29 09:43:21 2011
@@ -36,23 +36,21 @@ myfaces._impl.core._Runtime.singletonExt
 
     /**
      * determines fields to submit
-     * @param {Object} request the xhr request object
-     * @param {Object} context (Map)
-     * @param {Node} item - item that triggered the event
+     * @param {Object} targetBuf - the target form buffer receiving the data
      * @param {Node} parentItem - form element item is nested in
      * @param {Array} partialIds - ids fo PPS
      */
-    encodeSubmittableFields : function(targetBuf, request, context, item,
+    encodeSubmittableFields : function(targetBuf,
                                        parentItem, partialIds) {
 
-        try {
+        //try {
             if (!parentItem) {
-                context._mfInternal._onWarning(request, context, "myfaces._impl.xhrCore._AjaxUtils", "encodeSubmittableFields " + "Html-Component is not nested in a Form-Tag");
-                return null;
+            //    context._mfInternal._onWarning(request, context, "myfaces._impl.xhrCore._AjaxUtils", "encodeSubmittableFields " + "Html-Component is not nested in a Form-Tag");
+                throw "NO_PARITEM";
             }
 
-            if (partialIds && partialIds.length > 0) {
-                this.encodePartialSubmit(parentItem, item, false, partialIds, targetBuf);
+            if (partialIds ) {
+                this.encodePartialSubmit(parentItem, false, partialIds, targetBuf);
             } else {
                 // add all nodes
                 var eLen = parentItem.elements.length;
@@ -61,10 +59,9 @@ myfaces._impl.core._Runtime.singletonExt
                 } // end of for (formElements)
             }
 
-            this.appendIssuingItem(item, targetBuf);
-        } catch (e) {
-            context._mfInternal._onException(request, context, "myfaces._impl.xhrCore._AjaxUtils", "encodeSubmittableFields", e);
-        }
+        //} catch (e) {
+        //    context._mfInternal._onException(request, context, "myfaces._impl.xhrCore._AjaxUtils", "encodeSubmittableFields", e);
+        //}
     },
 
     /**
@@ -77,13 +74,13 @@ myfaces._impl.core._Runtime.singletonExt
      * Now this algorithm is up for discussion because it is relatively complex
      * but for now we will leave it as it is.
      *
-     * @param {Node} node - the root node of the partial page submit
+     * @param {Node} node - the root node of the partial page submit  (usually the form)
      * @param {boolean} submitAll - if set to true, all elements within this node will
      * be added to the partial page submit
      * @param {Array} partialIds - an array of partial ids which should be used for the submit
-     * @param {Array} targetBuf a target string buffer which receives the encoded elements
+     * @param {Object} targetBuf a target string buffer which receives the encoded elements
      */
-    encodePartialSubmit : function(node, issuingItem, submitAll,
+    encodePartialSubmit : function(node,  submitAll,
                                    partialIds, targetBuf) {
         var _Lang = myfaces._impl._util._Lang;
         var _Impl = myfaces._impl.core.Impl;