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 2023/11/21 20:32:09 UTC
(myfaces) branch 2.2.x updated: Apply updated MYFACES-4606 fix
This is an automated email from the ASF dual-hosted git repository.
werpu pushed a commit to branch 2.2.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/2.2.x by this push:
new d5d28a0e6 Apply updated MYFACES-4606 fix
new 29ab7ee7c Merge pull request #647 from volosied/4606-22x
d5d28a0e6 is described below
commit d5d28a0e6cae3ea22e021c64ecf474d6352bf900
Author: Volodymyr Siedlecki <vo...@gmail.com>
AuthorDate: Mon Nov 20 23:07:06 2023 -0500
Apply updated MYFACES-4606 fix
---
.../resources/myfaces/_impl/_util/_Lang.js | 27 ++++++++++++++++++----
.../resources/myfaces/_impl/xhrCore/_AjaxUtils.js | 23 ++++++++++++++----
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
index 32e9306c6..721aa267c 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
@@ -543,10 +543,16 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
//we simulate the dom level 2 form element here
var _newCls = null;
var bufInstance = null;
+ var _Lang = this;
if (!this.FormDataDecoratorArray) {
this.FormDataDecoratorArray = function (theFormData) {
this._valBuf = theFormData;
this._idx = {};
+ var _t = this;
+ _Lang.arrForEach(theFormData, function(item) {
+ var key = item[0];
+ _t._idx[decodeURIComponent(key)] = true;
+ });
};
_newCls = this.FormDataDecoratorArray;
_newCls.prototype.append = function (key, val) {
@@ -565,6 +571,12 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
this._preprocessedData = theFormData;
this._valBuf = [];
this._idx = {};
+ var _t = this;
+ var keyValuePairs = theFormData.split(/\&/gi);
+ _Lang.arrForEach(keyValuePairs, function(item) {
+ var key = _Lang.trim(item.split(/\=/gi)[0]);
+ _t._idx[decodeURIComponent(key)] = true;
+ });
};
_newCls = this.FormDataDecoratorString;
_newCls.prototype.append = function (key, val) {
@@ -573,7 +585,8 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
};
//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];
+ var _t = this;
+ return !!(this._idx[key]);
};
_newCls.prototype.makeFinal = function () {
if (this._preprocessedData != "") {
@@ -584,17 +597,23 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
};
}
if (!this.FormDataDecoratorOther) {
+ /**
+ * expected a form data object
+ * @param theFormData object of type form data or something similar
+ * @constructor
+ */
this.FormDataDecoratorOther = function (theFormData) {
- this._valBuf = theFormData;
+ this._valBuf = theFormData || [];
this._idx = {};
+
};
_newCls = this.FormDataDecoratorOther;
_newCls.prototype.append = function (key, val) {
- this._valBuf.append(key, val);
+ this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)]);
this._idx[key] = true;
};
_newCls.prototype.hasKey = function (key) {
- return !!this._idx[key];
+ return !!(this._idx[key] || this._valBuf.has(key));
};
_newCls.prototype.makeFinal = function () {
return this._valBuf;
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
index d41b8a457..006e24cdf 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
@@ -57,11 +57,24 @@ _MF_SINGLTN(_PFX_XHR+"_AjaxUtils", _MF_OBJECT,
*/
appendIssuingItem: function (item, targetBuf) {
// if triggered by a Button send it along
- if (item && item.type &&
- (item.type.toLowerCase() == "submit" ||
- item.type.toLowerCase() == "button" )) {
- //buttons not always have a name unlike inputs
- targetBuf.append(item.id || item.name, item.value);
+ var identifier = item.id || item.name;
+ var type = ((item && item.type) || "").toLowerCase();
+
+ if(targetBuf.hasKey(identifier)) { //already processed within the values
+ return;
+ }
+
+ //MYFACES-4606 we cannot send a value on an unchecked box as issuing element
+ var isCheckboxRadio = "checkbox" == type || "radio" == type;
+ if(isCheckboxRadio && !item.checked) {
+ return;
+ } else if (isCheckboxRadio) {
+ var value = ("undefined" == typeof item.value || null == item.value) ? true : item.value;
+ targetBuf.append(identifier, value);
+ //item must have a valid value to be able to be appended, without it no dice!
+ } else if(!(("undefined" == typeof item.value) || (null == item.value))) {
+ var itemValue = item.value;
+ targetBuf.append(identifier, itemValue);
}
},