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 2022/12/20 15:35:41 UTC
[myfaces] branch 2.3.x updated: https://issues.apache.org/jira/browse/MYFACES-4538: 2.3.x (#446)
This is an automated email from the ASF dual-hosted git repository.
werpu pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/2.3.x by this push:
new f7e054715 https://issues.apache.org/jira/browse/MYFACES-4538: 2.3.x (#446)
f7e054715 is described below
commit f7e054715d25da4504a3ced1159d96f6a79f82a7
Author: Werner Punz <we...@apache.org>
AuthorDate: Tue Dec 20 16:35:35 2022 +0100
https://issues.apache.org/jira/browse/MYFACES-4538: 2.3.x (#446)
* https://issues.apache.org/jira/browse/MYFACES-4538: unification between next and stable
(minimal changes in the core code, tested against old browsers)
---
api/src/assembler/jsdoc-compiler.xml | 1 -
api/src/assembler/jsfscripts-compiler.xml | 13 +-
api/src/assembler/jsfscripts-experimental.xml | 1 -
api/src/assembler/jsfscripts-legacy.xml | 11 +-
api/src/assembler/jsfscripts-minimal-compiler.xml | 13 +-
.../jsfscripts-minimal-modern-compiler.xml | 2 +-
.../assembler/jsfscripts-uncompressed-compiler.xml | 2 +-
.../jsfscripts-uncompressed-full-compiler.xml | 12 +-
.../META-INF/resources/myfaces/_impl/_util/_Dom.js | 104 +++---
.../resources/myfaces/_impl/_util/_Lang.js | 4 +-
.../META-INF/resources/myfaces/_impl/core/Impl.js | 118 +++++--
.../resources/myfaces/_impl/core/Object.js | 32 +-
.../resources/myfaces/_impl/core/_ExtRuntime.js | 40 +--
.../myfaces/_impl/core/jsf-uncompressed.js | 10 +-
.../{core/Object.js => quirks/ObjectQuirks.js} | 45 +--
.../_AjaxRequestQuirks.js} | 124 +------
.../myfaces/_impl/quirks/_AjaxResponseQuirks.js | 171 +++++++++
.../myfaces/_impl/{_util => quirks}/_DomQuirks.js | 30 ++
.../myfaces/_impl/{_util => quirks}/_LangQuirks.js | 0
.../_impl/{core => quirks}/_RuntimeQuirks.js | 0
.../myfaces/_impl/quirks/_TransportQuirks.js | 36 ++
.../resources/myfaces/_impl/quirks/readme.txt | 4 +
.../myfaces/_impl/xhrCore/_AjaxRequest.js | 224 +++++-------
.../myfaces/_impl/xhrCore/_AjaxRequestLevel2.js | 88 -----
.../myfaces/_impl/xhrCore/_AjaxResponse.js | 142 +++-----
.../{_ExtAjaxRequest.js => _FormDataRequest.js} | 40 ++-
.../resources/myfaces/_impl/xhrCore/_Transports.js | 391 +++++++++++++--------
.../META-INF/resources/myfaces/api/jsf.js | 4 +-
28 files changed, 909 insertions(+), 753 deletions(-)
diff --git a/api/src/assembler/jsdoc-compiler.xml b/api/src/assembler/jsdoc-compiler.xml
index 5b4bbe4e8..287768051 100644
--- a/api/src/assembler/jsdoc-compiler.xml
+++ b/api/src/assembler/jsdoc-compiler.xml
@@ -50,7 +50,6 @@
<include>**/_impl/xhrCore/engine/IFrame.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequestLevel2.js</include>
<!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
diff --git a/api/src/assembler/jsfscripts-compiler.xml b/api/src/assembler/jsfscripts-compiler.xml
index 6b2e7f29c..aac113196 100644
--- a/api/src/assembler/jsfscripts-compiler.xml
+++ b/api/src/assembler/jsfscripts-compiler.xml
@@ -43,7 +43,7 @@
<include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
- <include>**/_impl/core/_RuntimeQuirks.js</include>
+ <include>**/_impl/quirks/_RuntimeQuirks.js</include>
<include>**/_impl/core/_StartImpl.js</include>
<include>**/_impl/i18n/Messages.js</include>
@@ -58,14 +58,15 @@
<include>**/_impl/i18n/Messages_zh_TW.js</include>
<include>**/_impl/_util/_Lang.js</include>
- <include>**/_impl/_util/_LangQuirks.js</include>
+ <include>**/_impl/quirks/_LangQuirks.js</include>
<include>**/_impl/core/Object.js</include>
+ <include>**/_impl/quirks/ObjectQuirks.js</include>
<include>**/_impl/_util/_Queue.js</include>
<include>**/_impl/_util/_ListenerQueue.js</include>
<include>**/_impl/_util/_Dom.js</include>
<include>**/_impl/_util/_DomExperimental.js</include>
- <include>**/_impl/_util/_DomQuirks.js</include>
+ <include>**/_impl/quirks/_DomQuirks.js</include>
<include>**/_impl/_util/_HtmlStripper.js</include>
<include>**/_impl/_util/_OamSubmit.js</include>
@@ -81,13 +82,15 @@
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <include>**/_impl/xhrCore/_ExtAjaxRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequestLevel2.js</include>
+ <include>**/_impl/quirks/_AjaxRequestQuirks.js</include>
+ <include>**/_impl/xhrCore/_FormDataRequest.js</include>
<!-- this is pure 2.2 functionality -->
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
+ <include>**/_impl/quirks/_AjaxResponseQuirks.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
+ <include>**/_impl/quirks/_TransportQuirks.js</include>
<include>**/_impl/xhrCore/_ExtTransport.js</include>
<include>**/_impl/core/Impl.js</include>
<include>**/_impl/core/_EndImpl.js</include>
diff --git a/api/src/assembler/jsfscripts-experimental.xml b/api/src/assembler/jsfscripts-experimental.xml
index 1aceea95a..af06595ca 100644
--- a/api/src/assembler/jsfscripts-experimental.xml
+++ b/api/src/assembler/jsfscripts-experimental.xml
@@ -31,7 +31,6 @@
<include>**/_impl/_util/_DomExperimental.js</include>
<include>**/_impl/_util/_ExtDom.js</include>
<include>**/_impl/xhrCore/engine/IFrame.js</include>
- <include>**/_impl/xhrCore/_ExtAjaxRequest.js</include>
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_PartialSubmitUtils.js</include>
<include>**/_impl/xhrCore/_ExtTransports.js</include>
diff --git a/api/src/assembler/jsfscripts-legacy.xml b/api/src/assembler/jsfscripts-legacy.xml
index 679fa0f58..aff905e42 100644
--- a/api/src/assembler/jsfscripts-legacy.xml
+++ b/api/src/assembler/jsfscripts-legacy.xml
@@ -41,10 +41,15 @@
<script>
<fileName>jsf-legacy.js</fileName>
<includes>
- <include>**/_impl/core/_RuntimeQuirks.js</include>
+ <include>**/_impl/quirks/_RuntimeQuirks.js</include>
<include>**/_impl/core/_StartImpl.js</include>
- <include>**/_impl/_util/_LangQuirks.js</include>
- <include>**/_impl/_util/_DomQuirks.js</include>
+ <include>**/_impl/quirks/_LangQuirks.js</include>
+ <include>**/_impl/quirks/_ObjectQuirks.js</include>
+
+ <include>**/_impl/quirks/_DomQuirks.js</include>
+ <include>**/_impl/quirks/_AjaxResponseQuirks.js</include>
+ <include>**/_impl/quirks/_AjaxRequestQuirks.js</include>
+ <include>**/_impl/quirks/_TransportQuirks.js</include>
<include>**/_impl/core/_EndImpl.js</include>
</includes>
</script>
diff --git a/api/src/assembler/jsfscripts-minimal-compiler.xml b/api/src/assembler/jsfscripts-minimal-compiler.xml
index 9f97de760..85adedc93 100644
--- a/api/src/assembler/jsfscripts-minimal-compiler.xml
+++ b/api/src/assembler/jsfscripts-minimal-compiler.xml
@@ -28,18 +28,20 @@
<includes>
<include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
- <include>**/_impl/core/_RuntimeQuirks.js</include>
+ <include>**/_impl/quirks/_RuntimeQuirks.js</include>
<include>**/_impl/core/_StartImpl.js</include>
<include>**/_impl/i18n/Messages.js</include>
<include>**/_impl/_util/_Lang.js</include>
- <include>**/_impl/_util/_LangQuirks.js</include>
+ <include>**/_impl/quirks/_LangQuirks.js</include>
<include>**/_impl/core/Object.js</include>
+ <include>**/_impl/quirks/ObjectQuirks.js</include>
+
<include>**/_impl/_util/_Queue.js</include>
<include>**/_impl/_util/_ListenerQueue.js</include>
<include>**/_impl/_util/_Dom.js</include>
- <include>**/_impl/_util/_DomQuirks.js</include>
+ <include>**/_impl/quirks/_DomQuirks.js</include>
<include>**/_impl/_util/_HtmlStripper.js</include>
<include>**/_impl/_util/_OamSubmit.js</include>
@@ -54,10 +56,13 @@
<include>**/_impl/xhrCore/engine/IFrame.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequestLevel2.js</include>
+ <include>**/_impl/quirks/_AjaxRequestQuirks.js</include>
+ <include>**/_impl/xhrCore/_FormDataRequest.js</include>
<!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
+ <include>**/_impl/quirks/_AjaxResponseQuirks.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
+ <include>**/_impl/quirks/_TransportQuirks.js</include>
<include>**/_impl/core/Impl.js</include>
<!-- optimization helper -->
<include>**/_impl/core/_EndImpl.js</include>
diff --git a/api/src/assembler/jsfscripts-minimal-modern-compiler.xml b/api/src/assembler/jsfscripts-minimal-modern-compiler.xml
index 5d5207602..ed026d217 100644
--- a/api/src/assembler/jsfscripts-minimal-modern-compiler.xml
+++ b/api/src/assembler/jsfscripts-minimal-modern-compiler.xml
@@ -56,7 +56,7 @@
<include>**/_impl/xhrCore/engine/BaseRequest.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequestLevel2.js</include>
+ <include>**/_impl/xhrCore/_FormDataRequest.js</include>
<!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
diff --git a/api/src/assembler/jsfscripts-uncompressed-compiler.xml b/api/src/assembler/jsfscripts-uncompressed-compiler.xml
index a393be2dc..ccba98fa6 100644
--- a/api/src/assembler/jsfscripts-uncompressed-compiler.xml
+++ b/api/src/assembler/jsfscripts-uncompressed-compiler.xml
@@ -23,7 +23,7 @@
<includes>
<include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
- <include>**/_impl/core/_RuntimeQuirks.js</include>
+ <include>**/_impl/quirks/_RuntimeQuirks.js</include>
<include>**/_impl/core/jsf-uncompressed.js</include>
</includes>
</script>
diff --git a/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml b/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
index d8b107c7e..acaa87c50 100644
--- a/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
+++ b/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
@@ -43,7 +43,7 @@
<includes>
<include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
- <include>**/_impl/core/_RuntimeQuirks.js</include>
+ <include>**/_impl/quirks/_RuntimeQuirks.js</include>
<include>**/_impl/core/_StartImpl.js</include>
<include>**/_impl/i18n/Messages.js</include>
@@ -57,14 +57,15 @@
<include>**/_impl/i18n/Messages_zh_HK.js</include>
<include>**/_impl/i18n/Messages_zh_TW.js</include>
<include>**/_impl/_util/_Lang.js</include>
- <include>**/_impl/_util/_LangQuirks.js</include>
+ <include>**/_impl/quirks/_LangQuirks.js</include>
<include>**/_impl/core/Object.js</include>
+ <include>**/_impl/quirks/ObjectQuirks.js</include>
<include>**/_impl/_util/_Queue.js</include>
<include>**/_impl/_util/_ListenerQueue.js</include>
<include>**/_impl/_util/_Dom.js</include>
<include>**/_impl/_util/_DomExperimental.js</include>
- <include>**/_impl/_util/_DomQuirks.js</include>
+ <include>**/_impl/quirks/_DomQuirks.js</include>
<include>**/_impl/_util/_HtmlStripper.js</include>
<include>**/_impl/_util/_OamSubmit.js</include>
@@ -80,11 +81,14 @@
<include>**/_impl/xhrCore/engine/IFrame.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequestLevel2.js</include>
+ <include>**/_impl/quirks/_AjaxRequestQuirks.js</include>
+ <include>**/_impl/xhrCore/_FormDataRequest.js</include>
<!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
+ <include>**/_impl/quirks/_AjaxResponseQuirks.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
+ <include>**/_impl/quirks/_TransportQuirks.js</include>
<include>**/_impl/xhrCore/_ExtTransport.js</include>
<include>**/_impl/core/Impl.js</include>
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
index d5e3c378d..12ea4d648 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
@@ -115,9 +115,11 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
//we have to move this into an inner if because chrome otherwise chokes
//due to changing the and order instead of relying on left to right
//if jsf.js is already registered we do not replace it anymore
- if ((src.indexOf("ln=scripts") == -1 && src.indexOf("ln=javax.faces") == -1) || (src.indexOf("/jsf.js") == -1
- && src.indexOf("/jsf-uncompressed.js") == -1)) {
-
+ if ((src.indexOf("ln=scripts") == -1 && src.indexOf("ln=javax.faces") == -1) ||
+ (src.indexOf("/jsf.js") == -1
+ && (src.indexOf("/jsf-uncompressed.js") == -1)
+ && (src.indexOf("/jsf-development.js") == -1)
+ )) {
finalScripts = evalCollectedScripts(finalScripts);
_RT.loadScriptEval(src, item.getAttribute('type'), false, "UTF-8", false, nonce ? {nonce: nonce} : null );
}
@@ -304,9 +306,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
if (markup === "") return null;
var evalNodes = this._buildEvalNodes(item, markup),
- currentRef = item,
- parentNode = item.parentNode,
- ret = [];
+ currentRef = item,
+ parentNode = item.parentNode,
+ ret = [];
for (var cnt = evalNodes.length - 1; cnt >= 0; cnt--) {
currentRef = parentNode.insertBefore(evalNodes[cnt], currentRef);
ret.push(currentRef);
@@ -328,9 +330,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
if (markup === "") return null;
var evalNodes = this._buildEvalNodes(item, markup),
- currentRef = item,
- parentNode = item.parentNode,
- ret = [];
+ currentRef = item,
+ parentNode = item.parentNode,
+ ret = [];
for (var cnt = 0; cnt < evalNodes.length; cnt++) {
if (currentRef.nextSibling) {
@@ -362,24 +364,15 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
detectAttributes: function(element) {
//test if 'hasAttribute' method is present and its native code is intact
//for example, Prototype can add its own implementation if missing
+ //JSF 2.4 we now can reduce the complexity here, one of the functions now
+ //is definitely implemented
if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) {
return function(name) {
return element.hasAttribute(name);
}
} else {
- try {
- //when accessing .getAttribute method without arguments does not throw an error then the method is not available
- element.getAttribute;
-
- var html = element.outerHTML;
- var startTag = html.match(/^<[^>]*>/)[0];
- return function(name) {
- return startTag.indexOf(name + '=') > -1;
- }
- } catch (ex) {
- return function(name) {
- return element.getAttribute(name);
- }
+ return function (name) {
+ return !!element.getAttribute(name);
}
}
},
@@ -593,7 +586,6 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
*/
outerHTML : function(item, markup, preserveFocus) {
this._assertStdParams(item, markup, "outerHTML");
- markup = this._Lang.trim(markup);
// we can work on a single element in a cross browser fashion
// regarding the focus thanks to the
// icefaces team for providing the code
@@ -602,6 +594,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
this.cloneAttributes(item, replacingInput);
return item;
} else {
+ markup = this._Lang.trim(markup);
if (markup !== "") {
var ret = null;
@@ -771,9 +764,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
//elements bug, but it is mostly dom compliant so we have to give it a special
//treatment, IE9 finally fixes that issue finally after 10 years
evalNodes = (this.isDomCompliant() && nonIEQuirks) ?
- this._buildNodesCompliant(markup) :
- //ie8 or quirks mode browsers
- this._buildNodesNonCompliant(markup);
+ this._buildNodesCompliant(markup) :
+ //ie8 or quirks mode browsers
+ this._buildNodesNonCompliant(markup);
}
return evalNodes;
},
@@ -793,9 +786,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "_assertStdParams", "Caller must be set for assertion");
}
var _Lang = this._Lang,
- ERR_PROV = "ERR_MUST_BE_PROVIDED1",
- DOM = "myfaces._impl._util._Dom.",
- finalParams = params || ["item", "markup"];
+ ERR_PROV = "ERR_MUST_BE_PROVIDED1",
+ DOM = "myfaces._impl._util._Dom.",
+ finalParams = params || ["item", "markup"];
if (!item || !markup) {
_Lang.makeException(new Error(), null, null,DOM, ""+caller, _Lang.getMessage(ERR_PROV, null, DOM +"."+ caller, (!item) ? finalParams[0] : finalParams[1]));
@@ -851,8 +844,8 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
var parentNode = item.parentNode,
- sibling = item.nextSibling,
- resultArr = this._Lang.objToArray(evalNodes);
+ sibling = item.nextSibling,
+ resultArr = this._Lang.objToArray(evalNodes);
for (var cnt = 0; cnt < resultArr.length; cnt++) {
if (cnt == 0) {
@@ -925,7 +918,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
findByTagName : function(fragment, tagName) {
this._assertStdParams(fragment, tagName, "findByTagName", ["fragment", "tagName"]);
var _Lang = this._Lang,
- nodeType = fragment.nodeType;
+ nodeType = fragment.nodeType;
if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null;
//remapping to save a few bytes
@@ -992,8 +985,8 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
//we use the reject mechanism to prevent a deep scan reject means any
//child elements will be omitted from the scan
var FILTER_ACCEPT = NodeFilter.FILTER_ACCEPT,
- FILTER_SKIP = NodeFilter.FILTER_SKIP,
- FILTER_REJECT = NodeFilter.FILTER_REJECT;
+ FILTER_SKIP = NodeFilter.FILTER_SKIP,
+ FILTER_REJECT = NodeFilter.FILTER_REJECT;
var walkerFilter = function (node) {
var retCode = (filter(node)) ? FILTER_ACCEPT : FILTER_SKIP;
@@ -1073,10 +1066,10 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
return null;
}
- // This will not work well on portlet case, because we cannot be sure
- // the returned form is right one.
- //we can cover that case by simply adding one of our config params
- //the default is the weaker, but more correct portlet code
+ // This will not work well on portlet case, because we cannot be sure
+ // the returned form is right one.
+ //we can cover that case by simply adding one of our config params
+ //the default is the weaker, but more correct portlet code
//you can override it with myfaces_config.no_portlet_env = true globally
else if (1 == forms.length && this._RT.getGlobalConfig("no_portlet_env", false)) {
return forms[0];
@@ -1090,7 +1083,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
//https://issues.apache.org/jira/browse/MYFACES-2793
return (_Lang.equalsIgnoreCase(elem.tagName, "form")) ? elem :
- ( this.html5FormDetection(elem) || this.getParent(elem, "form"));
+ ( this.html5FormDetection(elem) || this.getParent(elem, "form"));
});
if (finalElem) {
@@ -1123,8 +1116,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
return (1 == foundElements.length ) ? foundElements[0] : null;
},
- html5FormDetection: function(/*item*/) {
- return null;
+ html5FormDetection:function (item) {
+ var elemForm = this.getAttribute(item, "form");
+ return (elemForm) ? this.byId(elemForm) : null;
},
@@ -1137,13 +1131,13 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
if (!item) {
throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "getParent",
- this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}"));
+ this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}"));
}
var _Lang = this._Lang;
var searchClosure = function(parentItem) {
return parentItem && parentItem.tagName
- && _Lang.equalsIgnoreCase(parentItem.tagName, tagName);
+ && _Lang.equalsIgnoreCase(parentItem.tagName, tagName);
};
try {
return this.getFilteredParent(item, searchClosure);
@@ -1262,6 +1256,30 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
return form[elementId];
},
+ /**
+ * backport new faces codebase, should work from ie9 onwards
+ * (cutoff point)
+ * builds the ie nodes properly in a placeholder
+ * and bypasses a non script insert bug that way
+ * @param markup the markup code to be executed from
+ */
+ fromMarkup: function(markup) {
+
+ // https:// developer.mozilla.org/de/docs/Web/API/DOMParser license creative commons
+ var doc = document.implementation.createHTMLDocument("");
+ var lowerMarkup = markup.toLowerCase();
+ if (lowerMarkup.indexOf('<!doctype') != -1 ||
+ lowerMarkup.indexOf('<html') != -1 ||
+ lowerMarkup.indexOf('<head') != -1 ||
+ lowerMarkup.indexOf('<body') != -1) {
+ doc.documentElement.innerHTML = markup;
+ return doc.documentElement;
+ } else {
+ var dummyPlaceHolder = document.createElement("div");
+ dummyPlaceHolder.innerHTML = markup;
+ return dummyPlaceHolder;
+ }
+ },
appendToHead: function(markup) {
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 3d9c377c4..ceea1573c 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
@@ -587,12 +587,12 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
}
if (!this.FormDataDecoratorOther) {
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) {
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
index 0274fa9e9..3d48d6abd 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
@@ -200,7 +200,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
source:elem,
onevent:options.onevent,
onerror:options.onerror,
-
+ viewId: "",
//TODO move the myfaces part into the _mfInternal part
myfaces:options.myfaces,
_mfInternal:{}
@@ -220,6 +220,8 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
_Lang.byId(options.myfaces.form) :
this._getForm(elem, event);
+ context.viewId = this.getViewId(form);
+
/**
* JSF2.2 client window must be part of the issuing form so it is encoded
* automatically in the request
@@ -276,13 +278,13 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
*/
options.execute = (options.execute.indexOf("@this") == -1) ? options.execute : options.execute;
- this._transformList(passThrgh, this.P_EXECUTE, options.execute, form, elementId);
+ this._transformList(passThrgh, this.P_EXECUTE, options.execute, form, elementId, context.viewId);
} else {
passThrgh[this.P_EXECUTE] = elementId;
}
if (options.render) {
- this._transformList(passThrgh, this.P_RENDER, options.render, form, elementId);
+ this._transformList(passThrgh, this.P_RENDER, options.render, form, elementId, context.viewId);
}
/**
@@ -307,7 +309,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
//this is not documented behavior but can be determined by running
//mojarra under blackbox conditions
//i assume it does the same as our formId_submit=1 so leaving it out
- //wont hurt but for the sake of compatibility we are going to add it
+ //won´t hurt but for the sake of compatibility we are going to add it
passThrgh[form.id] = form.id;
/* jsf2.2 only: options.delay || */
@@ -317,7 +319,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
if(!(delayTimeout >= 0)) {
// abbreviation which covers all cases of non positive values,
// including NaN and non-numeric strings, no type equality is deliberate here,
- throw new Error("Invalid delay value: " + value);
+ throw new Error("Invalid delay value: " + delayTimeout);
}
if (this._delayTimeout) {
clearTimeout(this._delayTimeout);
@@ -373,8 +375,8 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
//for now we turn off the transport auto selection, to enable 2.0 backwards compatibility
//on protocol level, the file upload only can be turned on if the auto selection is set to true
var getConfig = this._RT.getLocalOrGlobalConfig,
- _Lang = this._Lang,
- _Dom = this._Dom;
+ _Lang = this._Lang,
+ _Dom = this._Dom;
var transportAutoSelection = getConfig(context, "transportAutoSelection", true);
/*var isMultipart = (transportAutoSelection && _Dom.getAttribute(form, "enctype") == "multipart/form-data") ?
@@ -385,7 +387,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
return getConfig(context, "transportType", "xhrQueuedPost");
}
var multiPartCandidate = _Dom.isMultipartCandidate((!getConfig(context, "pps", false)) ?
- form : passThrgh[this.P_EXECUTE]);
+ form : passThrgh[this.P_EXECUTE]);
var multipartForm = (_Dom.getAttribute(form, "enctype") || "").toLowerCase() == "multipart/form-data";
//spec section jsdoc, if we have a multipart candidate in our execute (aka fileupload)
//and the form is not multipart then we have to raise an error
@@ -406,8 +408,8 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
*
*/
var transportType = (!isMultipart) ?
- getConfig(context, "transportType", "xhrQueuedPost") :
- getConfig(context, "transportType", "multipartQueuedPost");
+ getConfig(context, "transportType", "xhrQueuedPost") :
+ getConfig(context, "transportType", "multipartQueuedPost");
if (!this._transport[transportType]) {
//throw new Error("Transport type " + transportType + " does not exist");
throw new Error(_Lang.getMessage("ERR_TRANSPORT", null, transportType));
@@ -427,8 +429,9 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
* @param srcStr
* @param form
* @param elementId
+ * @param namingContainerId the naming container namingContainerId
*/
- _transformList:function (passThrgh, target, srcStr, form, elementId) {
+ _transformList:function (passThrgh, target, srcStr, form, elementId, namingContainerId) {
var _Lang = this._Lang;
//this is probably the fastest transformation method
//it uses an array and an index to position all elements correctly
@@ -436,14 +439,14 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
//false
srcStr = this._Lang.trim(srcStr);
var offset = 1,
- vals = (srcStr) ? srcStr.split(/\s+/) : [],
- idIdx = (vals.length) ? _Lang.arrToMap(vals, offset) : {},
+ vals = (srcStr) ? srcStr.split(/\s+/) : [],
+ idIdx = (vals.length) ? _Lang.arrToMap(vals, offset) : {},
- //helpers to improve speed and compression
- none = idIdx[this.IDENT_NONE],
- all = idIdx[this.IDENT_ALL],
- theThis = idIdx[this.IDENT_THIS],
- theForm = idIdx[this.IDENT_FORM];
+ //helpers to improve speed and compression
+ none = idIdx[this.IDENT_NONE],
+ all = idIdx[this.IDENT_ALL],
+ theThis = idIdx[this.IDENT_THIS],
+ theForm = idIdx[this.IDENT_FORM];
if (none) {
//in case of none nothing is returned
@@ -469,10 +472,63 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
}
//the final list must be blank separated
- passThrgh[target] = vals.join(" ");
+ passThrgh[target] = this._remapNamingContainer(elementId, form, namingContainerId,vals).join(" ");
return passThrgh;
},
+ /**
+ * in namespaced situations root naming containers must be resolved
+ * ":" absolute searches must be mapped accordingly, the same
+ * goes for absolut searches containing already the root naming container id
+ *
+ * @param issuingElementId the issuing element id
+ * @param form the hosting form of the issiung element id
+ * @param rootNamingContainerId the root naming container id
+ * @param elements a list of element client ids to be processed
+ * @returns {*} the mapped element client ids, which are resolved correctly to their naming containers
+ * @private
+ */
+ _remapNamingContainer: function(issuingElementId, form, rootNamingContainerId, elements) {
+ var SEP = jsf.separatorchar;
+ function remapViewId(toTransform) {
+ var EMPTY_STR = "";
+ var rootNamingContainerPrefix = (rootNamingContainerId.length) ? rootNamingContainerId+SEP : EMPTY_STR;
+ var formClientId = form.id;
+ // nearest parent naming container relative to the form
+ var nearestNamingContainer = formClientId.substring(0, formClientId.lastIndexOf(SEP));
+ var nearestNamingContainerPrefix = (nearestNamingContainer.length) ? nearestNamingContainer + SEP : EMPTY_STR;
+ // absolut search expression, always starts with SEP or the name of the root naming container
+ var hasLeadingSep = toTransform.indexOf(SEP) === 0;
+ var isAbsolutSearchExpr = hasLeadingSep || (rootNamingContainerId.length
+ && toTransform.indexOf(rootNamingContainerPrefix) == 0);
+ if (isAbsolutSearchExpr) {
+ //we cut off the leading sep if there is one
+ toTransform = hasLeadingSep ? toTransform.substring(1) : toTransform;
+ toTransform = toTransform.indexOf(rootNamingContainerPrefix) == 0 ? toTransform.substring(rootNamingContainerPrefix.length) : toTransform;
+ //now we prepend either the prefix or "" from the cut-off string to get the final result
+ return [rootNamingContainerPrefix, toTransform].join(EMPTY_STR);
+ } else { //relative search according to the javadoc
+ //we cut off the root naming container id from the form
+ if (formClientId.indexOf(rootNamingContainerPrefix) == 0) {
+ formClientId = formClientId.substring(rootNamingContainerPrefix.length);
+ }
+
+ //If prependId = true, the outer form id must be present in the id if same form
+ var hasPrependId = toTransform.indexOf(formClientId) == 0;
+
+ return hasPrependId ?
+ [rootNamingContainerPrefix, toTransform].join(EMPTY_STR) :
+ [nearestNamingContainerPrefix, toTransform].join(EMPTY_STR);
+ }
+ }
+
+ for(var cnt = 0; cnt < elements.length; cnt++) {
+ elements[cnt] = remapViewId(this._Lang.trim(elements[cnt]));
+ }
+
+ return elements;
+ },
+
addOnError:function (/*function*/errorListener) {
/*error handling already done in the assert of the queue*/
this._errListeners.enqueue(errorListener);
@@ -546,7 +602,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
if (jsf.getProjectStage() === "Development" && this._errListeners.length() == 0 && !context["onerror"]) {
var DIVIDER = "--------------------------------------------------------",
- defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert),
+ defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", (console && console.error) ? console.error : alert),
finalMessage = [],
//we remap the function to achieve a better compressability
pushMsg = _Lang.hitch(finalMessage, finalMessage.push);
@@ -671,7 +727,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
/* run through all script tags and try to find the one that includes jsf.js */
for (var i = 0; i < scriptTags.length && !found; i++) {
- if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1) {
+ if (scriptTags[i] && scriptTags[i].src && scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1) {
var result = scriptTags[i].src.match(/stage=([^&;]*)/);
found = true;
if (result) {
@@ -839,6 +895,26 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.
var forms = this._Dom.findByTagName(finalNode, "form");
var result = fetchWindowIdFromForms(forms);
return (null != result) ? result : fetchWindowIdFromURL();
+ },
+
+ /**
+ * returns the view id from an incoming form
+ * crossport from new codebase
+ * @param form
+ */
+ getViewId: function (form) {
+ var _t = this;
+ var foundViewStates = this._Dom.findAll(form, function(node) {
+ return node.tagName === "INPUT" && node.type === "hidden" && (node.name || "").indexOf(_t.P_VIEWSTATE) !== -1
+ }, true);
+ if(!foundViewStates.length) {
+ return "";
+ }
+ var viewId = foundViewStates[0].id.split(jsf.separatorchar, 2)[0];
+ var viewStateViewId = viewId.indexOf(this.P_VIEWSTATE) === -1 ? viewId : "";
+ // myfaces specific, we in non portlet environments prepend the viewId
+ // even without being in a naming container, the other components ignore that
+ return form.id.indexOf(viewStateViewId) === 0 ? viewStateViewId : "";
}
});
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
index 276add797..b0d1e1b2c 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
@@ -38,14 +38,6 @@ _MF_CLS(_PFX_CORE+"Object", Object, {
/*optional functionality can be provided
* for ie6 but is turned off by default*/
_initDefaultFinalizableFields: function() {
- var isIE = this._RT.browser.isIE;
- if(!isIE || isIE > 7) return;
- for (var key in this) {
- //per default we reset everything which is not preinitalized
- if (null == this[key] && key != "_resettableContent" && key.indexOf("_mf") != 0 && key.indexOf("_") == 0) {
- this._resettableContent[key] = true;
- }
- }
},
/**
@@ -55,21 +47,9 @@ _MF_CLS(_PFX_CORE+"Object", Object, {
* on other browsers this method does nothing
*/
_finalize: function() {
- try {
- if (this._isGCed || !this._RT.browser.isIE || !this._resettableContent) {
- //no ie, no broken garbage collector
- return;
- }
-
- for (var key in this._resettableContent) {
- if (this._RT.exists(this[key], "_finalize")) {
- this[key]._finalize();
- }
- delete this[key];
- }
- } finally {
- this._isGCed = true;
- }
+ // not needed anymore but to preserve
+ // the connection to quirks mode
+ // we keep it as empty implementation
},
attr: function(name, value) {
@@ -97,8 +77,6 @@ _MF_CLS(_PFX_CORE+"Object", Object, {
(function() {
/*some mobile browsers do not have a window object*/
var target = window ||document;
- var _RT = myfaces._impl.core._Runtime;
- _RT._MF_OBJECT = target._MF_OBJECT;
+ target._MF_OBJECT = myfaces._impl.core.Object;
- target._MF_OBJECT = myfaces._impl.core.Object;
-})();
+})();
\ No newline at end of file
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_ExtRuntime.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_ExtRuntime.js
index f5bf170f7..479803a1b 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_ExtRuntime.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_ExtRuntime.js
@@ -156,37 +156,37 @@
};
- _T.loadScript = function (src, type, defer, charSet, async, cspMeta) {
+ _T.loadScript = function (src, type, defer, charSet, async) {
//the chrome engine has a nasty javascript bug which prevents
//a correct order of scripts being loaded
//if you use script source on the head, we have to revert
//to xhr+ globalEval for those
var b = _T.browser;
if (!b.isFF && !b.isWebkit && !b.isOpera >= 10) {
- _T.loadScriptEval(src, type, defer, charSet, cspMeta);
+ _T.loadScriptEval(src, type, defer, charSet);
} else {
//only firefox keeps the order, sorry ie...
- _T.loadScriptByBrowser(src, type, defer, charSet, async, cspMeta);
+ _T.loadScriptByBrowser(src, type, defer, charSet, async);
}
};
- //internal class namespace reservation depending on the type (string or function)
- _T._reserveClsNms = function(newCls, protoFuncs) {
- var constr = null;
- var UDEF = "undefined";
- if (UDEF != typeof protoFuncs && null != protoFuncs) {
- constr = (UDEF != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() {
- };
- } else {
- constr = function() {
- };
- }
+ //internal class namespace reservation depending on the type (string or function)
+ _T._reserveClsNms = function(newCls, protoFuncs) {
+ var constr = null;
+ var UDEF = "undefined";
+ if (UDEF != typeof protoFuncs && null != protoFuncs) {
+ constr = (UDEF != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() {
+ };
+ } else {
+ constr = function() {
+ };
+ }
- if (!_T.reserveNamespace(newCls, constr)) {
- return null;
- }
- newCls = _T.fetchNamespace(newCls);
- return newCls;
- };
+ if (!_T.reserveNamespace(newCls, constr)) {
+ return null;
+ }
+ newCls = _T.fetchNamespace(newCls);
+ return newCls;
+ };
})();
\ No newline at end of file
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
index 967f61b46..6faed2776 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
@@ -30,13 +30,14 @@ if (!window.jsf) {
_ls("#{resource['org.apache.myfaces.core.impl.util:_Lang.js']}", null, null, "UTF-8", false);
- _ls("#{resource['org.apache.myfaces.core.impl.util:_LangQuirks.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.quirks:_LangQuirks.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.core:Object.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.quirks:ObjectQuirks.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_Queue.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_ListenerQueue.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_Dom.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_DomExperimental.js']}", null, null, "UTF-8", false);
- _ls("#{resource['org.apache.myfaces.core.impl.util:_DomQuirks.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.quirks:_DomQuirks.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_HtmlStripper.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.util:_OamSubmit.js']}", null, null, "UTF-8", false);
@@ -54,11 +55,12 @@ if (!window.jsf) {
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8", false);
- _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_ExtAjaxRequest.js']}", null, null, "UTF-8", false);
- _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestLevel2.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQuirks.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_FormDataRequest.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_IFrameRequest.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.quirks:_AjaxResponseQuirks.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_ExtTransport.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.core:Impl.js']}", null, null, "UTF-8", false);
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/ObjectQuirks.js
similarity index 66%
copy from api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
copy to api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/ObjectQuirks.js
index 276add797..5f8305842 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Object.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/ObjectQuirks.js
@@ -16,23 +16,12 @@
/**
Base class which provides several helper functions over all objects
*/
-_MF_CLS(_PFX_CORE+"Object", Object, {
+_MF_CLS(_PFX_CORE+"ObjectQuirks", myfaces._impl.core.Object, {
constructor_: function() {
- this._resettableContent = {};
- //to make those singleton references
- //overridable in the instance we have
- //to load them into the prototype instead
- //of the instance
- var proto = this._mfClazz.prototype;
- var impl = myfaces._impl;
- if(!proto._RT) {
- proto._RT = impl.core._Runtime;
- proto._Lang = impl._util._Lang;
- proto._Dom = impl._util._Dom;
- }
+ this._callSuper("constructor_");
},
/*optional functionality can be provided
@@ -70,35 +59,17 @@ _MF_CLS(_PFX_CORE+"Object", Object, {
} finally {
this._isGCed = true;
}
- },
-
- attr: function(name, value) {
- return this._Lang.attr(this, name, value);
- },
-
- getImpl: function() {
- this._Impl = this._Impl || this._RT.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- return this._Impl;
- },
-
- applyArgs: function(args) {
- this._Lang.applyArgs(this, args);
- },
-
- updateSingletons: function(key) {
- var _T = this;
- _T._RT.iterateSingletons(function(namespace) {
- if(namespace[key]) namespace[key] = _T;
- });
}
-
});
(function() {
/*some mobile browsers do not have a window object*/
var target = window ||document;
- var _RT = myfaces._impl.core._Runtime;
- _RT._MF_OBJECT = target._MF_OBJECT;
- target._MF_OBJECT = myfaces._impl.core.Object;
+ // we still reuse the other namespaces for our quirks module, to avoid
+ // specific quirks code on our core code
+ // this class is a full replacement of Object, not just
+ // an extension
+ target._MF_OBJECT = myfaces._impl.core.ObjectQuirks;
+
})();
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxRequestQuirks.js
similarity index 74%
copy from api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
copy to api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxRequestQuirks.js
index c0a7c254c..b2fb88a31 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxRequestQuirks.js
@@ -23,91 +23,10 @@
* Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
*/
-/**
- * @class
- * @name _AjaxRequest
- * @memberOf myfaces._impl.xhrCore
- * @extends myfaces._impl.core.Object
- */
-_MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */ {
-
- _contentType:"application/x-www-form-urlencoded",
- /** source element issuing the request */
- _source:null,
- /** context passed down from the caller */
- _context:null,
- /** source form issuing the request */
- _sourceForm:null,
- /** passthrough parameters */
- _passThrough:null,
-
- /** queue control */
- _timeout:null,
- /** enqueuing delay */
- //_delay:null,
- /** queue size */
- _queueSize:-1,
-
- /**
- back reference to the xhr queue,
- only set if the object really is queued
- */
- _xhrQueue:null,
-
- /** pps an array of identifiers which should be part of the submit, the form is ignored */
- _partialIdsArray:null,
-
- /** xhr object, internal param */
- _xhr:null,
-
- /** predefined method */
- _ajaxType:"POST",
-
- //CONSTANTS
- ENCODED_URL:"javax.faces.encodedURL",
- /*
- * constants used internally
- */
- _CONTENT_TYPE:"Content-Type",
- _HEAD_FACES_REQ:"Faces-Request",
- _VAL_AJAX:"partial/ajax",
- _XHR_CONST:myfaces._impl.xhrCore.engine.XhrConst,
-
- // _exception: null,
- // _requestParameters: null,
- /**
- * Constructor
- * <p />
- * note there is a load of common properties
- * inherited by the base class which define the corner
- * parameters and the general internal behavior
- * like _onError etc...
- * @param {Object} args an arguments map which an override any of the given protected
- * instance variables, by a simple name value pair combination
- */
- constructor_:function (args) {
-
- try {
- this._callSuper("constructor_", args);
-
- this._initDefaultFinalizableFields();
- delete this._resettableContent["_xhrQueue"];
-
- this.applyArgs(args);
-
- /*namespace remapping for readability*/
- //we fetch in the standard arguments
- //and apply them to our protected attributes
- //we do not gc the entry hence it is not defined on top
- var xhrCore = myfaces._impl.xhrCore;
- this._AJAXUTIL = xhrCore._AjaxUtils;
-
- } catch (e) {
- //_onError
- this._stdErrorHandler(this._xhr, this._context, e);
- }
+_MF_CLS(_PFX_XHR + "_AjaxRequestQuirks", myfaces._impl.xhrCore._AjaxRequest, /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */ {
+ constructor_: function (args) {
+ this._callSuper("constructor_", args);
},
-
/**
* Sends an Ajax request
*/
@@ -135,11 +54,11 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
this._applyClientWindowId();
var xhr = this._xhr,
- sourceForm = this._sourceForm,
- targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ?
- sourceForm.action :
- sourceForm.elements[this.ENCODED_URL].value,
- formData = this.getFormData();
+ sourceForm = this._sourceForm,
+ targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ?
+ sourceForm.action :
+ sourceForm.elements[this.ENCODED_URL].value,
+ formData = this.getFormData();
for (var key in this._passThrough) {
if (!this._passThrough.hasOwnProperty(key)) continue;
@@ -147,8 +66,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
}
xhr.open(this._ajaxType, targetURL +
- ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
- , true);
+ ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
+ , true);
xhr.timeout = this._timeout || 0;
@@ -207,20 +126,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
}
},
- /**
- * applies the content type, this needs to be done only for xhr
- * level1
- * @param xhr
- * @private
- */
- _applyContentType:function (xhr) {
- var contentType = this._contentType + "; charset=utf-8";
- xhr.setRequestHeader(this._CONTENT_TYPE, contentType);
- },
- ondone:function () {
- this._requestDone();
- },
onsuccess:function (/*evt*/) {
this._restoreClientWindowId();
@@ -267,7 +173,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
try {
var _Impl = this.attr("impl");
_Impl.sendError(xhr, context, _Impl.HTTPERROR,
- _Impl.HTTPERROR, errorText, "", "myfaces._impl.xhrCore._AjaxRequest", "onerror");
+ _Impl.HTTPERROR, errorText, "", "myfaces._impl.xhrCore._AjaxRequest", "onerror");
} finally {
//add for xhr level2 support
//since chrome does not call properly the onloadend we have to do it manually
@@ -279,9 +185,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
//_onError
},
- onprogress:function (/*evt*/) {
- //do nothing for now
- },
ontimeout:function (/*evt*/) {
try {
@@ -375,5 +278,10 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
this._callSuper("_finalize");
}
}
+
});
+(function() {
+ /*some mobile browsers do not have a window object*/
+ myfaces._impl.xhrCore._AjaxRequest = myfaces._impl.xhrCore._AjaxRequestQuirks;
+})();
\ No newline at end of file
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxResponseQuirks.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxResponseQuirks.js
new file mode 100644
index 000000000..66dd3cf79
--- /dev/null
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_AjaxResponseQuirks.js
@@ -0,0 +1,171 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @class
+ * @name _AjaxResponse
+ * @memberOf myfaces._impl.xhrCore
+ * @extends myfaces._impl.core.Object
+ * @description
+ * This singleton is responsible for handling the standardized xml ajax response
+ * Note: since the semantic processing can be handled about 90% in a functional
+ * style we make this class stateless. Every state information is stored
+ * temporarily in the context.
+ *
+ * Ajax Response overrides for IE quirks mode
+ *
+ */
+_MF_SINGLTN(_PFX_XHR + "_AjaxResponseQuirks", myfaces._impl.xhrCore._AjaxResponse, /** @lends myfaces._impl.xhrCore._AjaxResponse.prototype */ {
+ constructor_: function() {
+ this._callSuper("constructor_");
+ myfaces._impl.xhrCore._AjaxResponse = this;
+ },
+
+ /**
+ * replaces a current head theoretically,
+ * pratically only the scripts are evaled anew since nothing else
+ * can be changed.
+ *
+ * @param request the current request
+ * @param context the ajax context
+ * @param newData the data to be processed
+ *
+ * @return an xml representation of the page for further processing if possible
+ */
+ _replaceHead: function (request, context, newData) {
+ var _Lang = this._Lang,
+ _Dom = this._Dom,
+ _RT = this._RT,
+ isWebkit = this._RT.browser.isWebKit,
+ //we have to work around an xml parsing bug in Webkit
+ //see https://issues.apache.org/jira/browse/MYFACES-3061
+ doc = (!isWebkit) ? _Lang.parseXML(newData) : null,
+ newHead = null;
+
+ if (!isWebkit && _Lang.isXMLParseError(doc)) {
+ doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->"));
+ }
+
+ if (isWebkit || _Lang.isXMLParseError(doc)) {
+ //the standard xml parser failed we retry with the stripper
+ var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+ var headData = parser.parse(newData, "head");
+ //We cannot avoid it here, but we have reduced the parsing now down to the bare minimum
+ //for further processing
+ newHead = _Lang.parseXML("<head>" + headData + "</head>");
+ //last and slowest option create a new head element and let the browser
+ //do its slow job
+ if (_Lang.isXMLParseError(newHead)) {
+ try {
+ newHead = _Dom.createElement("head");
+ newHead.innerHTML = headData;
+ } catch (e) {
+ //we give up no further fallbacks
+ throw this._raiseError(new Error(), "Error head replacement failed reason:" + e.toString(), "_replaceHead");
+ }
+ }
+ newHead = newHead.childNodes[0];
+ } else {
+ //parser worked we go on
+ newHead = doc.getElementsByTagName("head")[0];
+ }
+
+ var oldTags = _Lang.objToArray(document.head.childNodes);
+
+
+ _Dom.deleteItems(_Lang.objToArray(oldTags));
+ _Dom.appendToHead(newHead);
+
+
+ return document.head;
+ },
+
+ /**
+ * special method to handle the body dom manipulation,
+ * replacing the entire body does not work fully by simply adding a second body
+ * and by creating a range instead we have to work around that by dom creating a second
+ * body and then filling it properly!
+ *
+ * @param {Object} request our request object
+ * @param {Object} context (Map) the response context
+ * @param {String} newData the markup which replaces the old dom node!
+ * @param {Node} parsedData (optional) preparsed XML representation data of the current document
+ */
+ _replaceBody: function (request, context, newData /*varargs*/) {
+ var _RT = this._RT,
+ _Dom = this._Dom,
+ _Lang = this._Lang,
+
+ oldBody = document.getElementsByTagName("body")[0],
+ placeHolder = document.createElement("div"),
+ isWebkit = _RT.browser.isWebKit;
+
+ placeHolder.id = "myfaces_bodyplaceholder";
+
+ _Dom._removeChildNodes(oldBody);
+ oldBody.innerHTML = "";
+ oldBody.appendChild(placeHolder);
+
+ var bodyData, doc = null, parser;
+
+ //we have to work around an xml parsing bug in Webkit
+ //see https://issues.apache.org/jira/browse/MYFACES-3061
+ if (!isWebkit) {
+ doc = (arguments.length > 3) ? arguments[3] : _Lang.parseXML(newData);
+ }
+
+ if (!isWebkit && _Lang.isXMLParseError(doc)) {
+ doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->"));
+ }
+
+ if (isWebkit || _Lang.isXMLParseError(doc)) {
+ //the standard xml parser failed we retry with the stripper
+
+ parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+
+ bodyData = parser.parse(newData, "body");
+ } else {
+ //parser worked we go on
+ var newBodyData = doc.getElementsByTagName("body")[0];
+
+ //speedwise we serialize back into the code
+ //for code reduction, speedwise we will take a small hit
+ //there which we will clean up in the future, but for now
+ //this is ok, I guess, since replace body only is a small subcase
+ //bodyData = _Lang.serializeChilds(newBodyData);
+ var browser = _RT.browser;
+ if (!browser.isIEMobile || browser.isIEMobile >= 7) {
+ //TODO check what is failing there
+ for (var cnt = 0; cnt < newBodyData.attributes.length; cnt++) {
+ var value = newBodyData.attributes[cnt].value;
+ if (value)
+ _Dom.setAttribute(oldBody, newBodyData.attributes[cnt].name, value);
+ }
+ }
+ }
+ //we cannot serialize here, due to escape problems
+ //we must parse, this is somewhat unsafe but should be safe enough
+ parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+ bodyData = parser.parse(newData, "body");
+
+ var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData);
+
+ if (returnedElement) {
+ this._pushOperationResult(context, returnedElement);
+ }
+ return returnedElement;
+ },
+});
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_DomQuirks.js
similarity index 95%
rename from api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js
rename to api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_DomQuirks.js
index 89e93a700..21e78720d 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_DomQuirks.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_DomQuirks.js
@@ -592,6 +592,36 @@ if (_MF_SINGLTN) {
} else {
return form[elementName];
}
+ },
+
+ detectAttributes: function(element) {
+ //test if 'hasAttribute' method is present and its native code is intact
+ //for example, Prototype can add its own implementation if missing
+ //JSF 2.4 we now can reduce the complexity here, one of the functions now
+ //is definitely implemented
+ if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) {
+ return function(name) {
+ return element.hasAttribute(name);
+ }
+ } else {
+ try {
+ //when accessing .getAttribute method without arguments does not throw an error then the method is not available
+ element.getAttribute;
+
+ var html = element.outerHTML;
+ var startTag = html.match(/^<[^>]*>/)[0];
+ return function(name) {
+ return startTag.indexOf(name + '=') > -1;
+ }
+ } catch (ex) {
+ return function(name) {
+ return element.getAttribute(name);
+ }
+ }
+ }
+ },
+ html5FormDetection: function(/*item*/) {
+ return null;
}
});
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_LangQuirks.js
similarity index 100%
rename from api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js
rename to api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_LangQuirks.js
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_RuntimeQuirks.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_RuntimeQuirks.js
similarity index 100%
rename from api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_RuntimeQuirks.js
rename to api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_RuntimeQuirks.js
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_TransportQuirks.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_TransportQuirks.js
new file mode 100644
index 000000000..fdcdb23f4
--- /dev/null
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/_TransportQuirks.js
@@ -0,0 +1,36 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+_MF_SINGLTN(_PFX_XHR + "_TransportsQuirks", myfaces._impl.xhrCore._Transports,
+ /** @lends myfaces._impl.xhrCore._Transports.prototype */ {
+ constructor_: function () {
+ this._callSuper("constructor_");
+ myfaces._impl.xhrCore._Transports = this;
+ },
+ /**
+ * centralized transport switching helper
+ * for the multipart submit case
+ *
+ * @param context the context which is passed down
+ */
+ _getMultipartReqClass: function (context) {
+ if (this._RT.getXHRLvl() >= 2) {
+ return myfaces._impl.xhrCore._FormDataRequest;
+ } else {
+ return myfaces._impl.xhrCore._IFrameRequest;
+ }
+ }
+ });
\ No newline at end of file
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/readme.txt b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/readme.txt
new file mode 100644
index 000000000..410e8b8ae
--- /dev/null
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/quirks/readme.txt
@@ -0,0 +1,4 @@
+Quirks overrides for legacy browsers (mostly internet explorer)
+
+if you do not have to support any of those browsers
+you can drop the entire package from the build
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
index c0a7c254c..8ad45102a 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
@@ -31,18 +31,18 @@
*/
_MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */ {
- _contentType:"application/x-www-form-urlencoded",
+ _contentType: "application/x-www-form-urlencoded",
/** source element issuing the request */
- _source:null,
+ _source: null,
/** context passed down from the caller */
_context:null,
/** source form issuing the request */
- _sourceForm:null,
+ _sourceForm: null,
/** passthrough parameters */
- _passThrough:null,
+ _passThrough: null,
/** queue control */
- _timeout:null,
+ _timeout: null,
/** enqueuing delay */
//_delay:null,
/** queue size */
@@ -52,13 +52,13 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
back reference to the xhr queue,
only set if the object really is queued
*/
- _xhrQueue:null,
+ _xhrQueue: null,
/** pps an array of identifiers which should be part of the submit, the form is ignored */
- _partialIdsArray:null,
+ _partialIdsArray : null,
/** xhr object, internal param */
- _xhr:null,
+ _xhr: null,
/** predefined method */
_ajaxType:"POST",
@@ -70,8 +70,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
*/
_CONTENT_TYPE:"Content-Type",
_HEAD_FACES_REQ:"Faces-Request",
- _VAL_AJAX:"partial/ajax",
- _XHR_CONST:myfaces._impl.xhrCore.engine.XhrConst,
+ _VAL_AJAX: "partial/ajax",
+ _XHR_CONST: myfaces._impl.xhrCore.engine.XhrConst,
// _exception: null,
// _requestParameters: null,
@@ -85,7 +85,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
* @param {Object} args an arguments map which an override any of the given protected
* instance variables, by a simple name value pair combination
*/
- constructor_:function (args) {
+ constructor_: function(args) {
try {
this._callSuper("constructor_", args);
@@ -111,44 +111,40 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
/**
* Sends an Ajax request
*/
- send:function () {
+ send : function() {
var _Lang = this._Lang;
var _RT = this._RT;
- var _Dom = this._Dom;
+
try {
- var scopeThis = _Lang.hitch(this, function (functionName) {
+ var scopeThis = _Lang.hitch(this, function(functionName) {
return _Lang.hitch(this, this[functionName]);
});
this._xhr = _Lang.mixMaps(this._getTransport(), {
- onprogress:scopeThis("onprogress"),
- ontimeout:scopeThis("ontimeout"),
- //remove for xhr level2 support (chrome has problems with it)
- //for chrome we have to emulate the onloadend by calling it explicitely
- //and leave the onload out
- //onloadend: scopeThis("ondone"),
- onload:scopeThis("onsuccess"),
- onerror:scopeThis("onerror")
+ onprogress: scopeThis("onprogress"),
+ ontimeout: scopeThis("ontimeout"),
+ //remove for xhr level2 support (chrome has problems with it)
+ onloadend: scopeThis("ondone"),
+ onload: scopeThis("onsuccess"),
+ onerror: scopeThis("onerror")
}, true);
-
- this._applyClientWindowId();
var xhr = this._xhr,
- sourceForm = this._sourceForm,
- targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ?
- sourceForm.action :
- sourceForm.elements[this.ENCODED_URL].value,
- formData = this.getFormData();
+ sourceForm = this._sourceForm,
+ targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ?
+ sourceForm.action :
+ sourceForm.elements[this.ENCODED_URL].value,
+ formData = this.getFormData();
for (var key in this._passThrough) {
- if (!this._passThrough.hasOwnProperty(key)) continue;
+ if(!this._passThrough.hasOwnProperty(key)) continue;
formData.append(key, this._passThrough[key]);
}
xhr.open(this._ajaxType, targetURL +
- ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
- , true);
+ ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
+ , true);
xhr.timeout = this._timeout || 0;
@@ -157,8 +153,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
//some webkit based mobile browsers do not follow the w3c spec of
// setting the accept headers automatically
- if (this._RT.browser.isWebKit) {
- xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+ if(this._RT.browser.isWebKit) {
+ xhr.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
}
this._sendEvent("BEGIN");
//Check if it is a custom form data object
@@ -170,60 +166,28 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
} catch (e) {
//_onError//_onError
- e = (e._mfInternal) ? e : this._Lang.makeException(new Error(), "sendError", "sendError", this._nameSpace, "send", e.message);
+ e = (e._mfInternal)? e: this._Lang.makeException(new Error(), "sendError","sendError", this._nameSpace, "send", e.message);
this._stdErrorHandler(this._xhr, this._context, e);
- } finally {
- //no finally possible since the iframe uses real asynchronousity
- }
- },
-
- _applyClientWindowId:function () {
- var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
- //pass through if exists already set by _Impl
- if ('undefined' != typeof this._context._mfInternal._clientWindow) {
- this._context._mfInternal._clientWindowOld = clientWindow.value;
- clientWindow.value = this._context._mfInternal._clientWindow;
- } else {
- if(clientWindow) {
- this._context._mfInternal._clientWindowDisabled = !! clientWindow.disabled;
- clientWindow.disabled = true;
- }
- }
- },
-
- _restoreClientWindowId:function () {
- //we have to reset the client window back to its original state
-
- var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
- if(!clientWindow) {
- return;
- }
- if ('undefined' != typeof this._context._mfInternal._clientWindowOld) {
- clientWindow.value = this._context._mfInternal._clientWindow;
- }
- if('undefined' != typeof this._context._mfInternal._clientWindowDisabled) {
- //we reset it to the old value
- clientWindow.disabled = this._context._mfInternal._clientWindowDisabled;
}
},
/**
- * applies the content type, this needs to be done only for xhr
- * level1
- * @param xhr
- * @private
+ * helper, in multipart situations we might alter the content type
+ * from the urlencoded one
*/
- _applyContentType:function (xhr) {
- var contentType = this._contentType + "; charset=utf-8";
+ _applyContentType: function(xhr) {
+ var contentType = this._contentType+"; charset=utf-8";
+
xhr.setRequestHeader(this._CONTENT_TYPE, contentType);
},
- ondone:function () {
+ ondone: function() {
this._requestDone();
},
- onsuccess:function (/*evt*/) {
- this._restoreClientWindowId();
+
+ onsuccess: function(/*evt*/) {
+
var context = this._context;
var xhr = this._xhr;
try {
@@ -234,18 +198,19 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
context._mfInternal = context._mfInternal || {};
jsf.ajax.response((xhr.getXHRObject) ? xhr.getXHRObject() : xhr, context);
+
+
} catch (e) {
this._stdErrorHandler(this._xhr, this._context, e);
-
- //add for xhr level2 support
- } finally {
- //W3C spec onloadend must be called no matter if success or not
- this.ondone();
}
+ //add for xhr level2 support
+ //} finally {
+ //W3C spec onloadend must be called no matter if success or not
+ // this.ondone();
+ //}
},
- onerror:function (/*evt*/) {
- this._restoreClientWindowId();
+ onerror: function(/*evt*/) {
//TODO improve the error code detection here regarding server errors etc...
//and push it into our general error handling subframework
var context = this._context;
@@ -257,35 +222,31 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
try {
var UNKNOWN = _Lang.getMessage("UNKNOWN");
//status can be 0 and statusText can be ""
- var status = ('undefined' != xhr.status && null != xhr.status) ? xhr.status : UNKNOWN;
- var statusText = ('undefined' != xhr.statusText && null != xhr.statusText) ? xhr.statusText : UNKNOWN;
- errorText = _Lang.getMessage("ERR_REQU_FAILED", null, status, statusText);
+ var status = ('undefined' != xhr.status && null != xhr.status)? xhr.status : UNKNOWN;
+ var statusText = ('undefined' != xhr.statusText && null != xhr.statusText)? xhr.statusText : UNKNOWN;
+ errorText = _Lang.getMessage("ERR_REQU_FAILED", null,status,statusText);
} catch (e) {
errorText = _Lang.getMessage("ERR_REQ_FAILED_UNKNOWN", null);
} finally {
- try {
- var _Impl = this.attr("impl");
+ var _Impl = this.attr("impl");
_Impl.sendError(xhr, context, _Impl.HTTPERROR,
- _Impl.HTTPERROR, errorText, "", "myfaces._impl.xhrCore._AjaxRequest", "onerror");
- } finally {
- //add for xhr level2 support
- //since chrome does not call properly the onloadend we have to do it manually
- //to eliminate xhr level1 for the compile profile modern
- //W3C spec onloadend must be called no matter if success or not
- this.ondone();
- }
+ _Impl.HTTPERROR, errorText,"","myfaces._impl.xhrCore._AjaxRequest","onerror");
+ //add for xhr level2 support
+ //since chrome does not call properly the onloadend we have to do it manually
+ //to eliminate xhr level1 for the compile profile modern
+ //W3C spec onloadend must be called no matter if success or not
+ //this.ondone();
}
//_onError
},
- onprogress:function (/*evt*/) {
+ onprogress: function(/*evt*/) {
//do nothing for now
},
- ontimeout:function (/*evt*/) {
+ ontimeout: function(/*evt*/) {
try {
- this._restoreClientWindowId();
//we issue an event not an error here before killing the xhr process
this._sendEvent("TIMEOUT_EVENT");
//timeout done we process the next in the queue
@@ -294,45 +255,59 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
}
},
- _formDataToURI:function (formData) {
+ _formDataToURI: function(formData) {
if (formData && formData.makeFinal) {
formData = formData.makeFinal()
}
return formData;
},
- _getTransport:function () {
-
- var xhr = this._RT.getXHRObject();
- //the current xhr level2 timeout w3c spec is not implemented by the browsers yet
- //we have to do a fallback to our custom routines
-
- //add for xhr level2 support
- //Chrome fails in the current builds, on our loadend, we disable the xhr
- //level2 optimisations for now
- if (/*('undefined' == typeof this._timeout || null == this._timeout) &&*/ this._RT.getXHRLvl() >= 2) {
- //no timeout we can skip the emulation layer
- return xhr;
- }
- return new myfaces._impl.xhrCore.engine.Xhr1({xhrObject:xhr});
+ /**
+ * change for jsf 2.3 since we drop legacy browser support
+ * there is no need anymore to support xhr level 1.
+ * @returns {XMLHttpRequest} the transport object
+ * @private
+ */
+ _getTransport: function() {
+ return new XMLHttpRequest();
},
+
//----------------- backported from the base request --------------------------------
//non abstract ones
+
+
/**
* Spec. 13.3.1
* Collect and encode input elements.
* Additionally the hidden element javax.faces.ViewState
- *
+ * Enhancement partial page submit
*
* @return an element of formDataWrapper
* which keeps the final Send Representation of the
*/
- getFormData:function () {
- var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces;
- return this._Lang.createFormDataDecorator(jsf.getViewState(this._sourceForm));
+ getFormData : function() {
+ var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces, ret = null;
+
+
+
+ if (!this._partialIdsArray || !this._partialIdsArray.length) {
+ var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces;
+ return this._Lang.createFormDataDecorator(jsf.getViewState(this._sourceForm));
+ } else {
+ //now this is less performant but we have to call it to allow viewstate decoration
+ ret = this._Lang.createFormDataDecorator(new Array());
+ _AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, this._partialIdsArray);
+ if (this._source && myfacesOptions && myfacesOptions.form)
+ _AJAXUTIL.appendIssuingItem(this._source, ret);
+
+ }
+ return ret;
+
},
+
+
/**
* Client error handlers which also in the long run route into our error queue
* but also are able to deliver more meaningful messages
@@ -343,7 +318,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
* @param context the context holding all values for further processing
* @param exception the embedded exception
*/
- _stdErrorHandler:function (request, context, exception) {
+ _stdErrorHandler: function(request, context, exception) {
var xhrQueue = this._xhrQueue;
try {
this.attr("impl").stdErrorHandler(request, context, exception);
@@ -354,26 +329,19 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.
}
},
- _sendEvent:function (evtType) {
+ _sendEvent: function(evtType) {
var _Impl = this.attr("impl");
_Impl.sendEvent(this._xhr, this._context, _Impl[evtType]);
},
- _requestDone:function () {
+ _requestDone: function() {
var queue = this._xhrQueue;
if (queue) {
queue.processQueue();
}
//ie6 helper cleanup
delete this._context.source;
- this._finalize();
- },
- //cleanup
- _finalize:function () {
- if (this._xhr.readyState == this._XHR_CONST.READY_STATE_DONE) {
- this._callSuper("_finalize");
- }
}
});
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js
deleted file mode 100644
index 443be5841..000000000
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * this method is used only for pure multipart form parts
- * otherwise the normal method is used
- * IT is a specialized request which uses the form data
- * element for the handling of forms
- */
-_MF_CLS(_PFX_XHR + "_MultipartAjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, {
-
- _sourceForm:null,
-
- constructor_:function (args) {
- this._callSuper("constructor_", args);
- //TODO xhr level2 can deal with real props
-
- },
-
- getFormData:function () {
- var ret;
- //in case of a multipart form post we savely can use the FormData object
- if (this._context._mfInternal.xhrOp === "multipartQueuedPost") {
- ret = new FormData(this._sourceForm);
- this._AJAXUTIL.appendIssuingItem(this._source, ret);
- } else {
- //we switch back to the encode submittable fields system
- this._AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, null);
- this._AJAXUTIL.appendIssuingItem(this._source, ret);
- }
- return ret;
- },
-
- /**
- * applies the content type, this needs to be done only for xhr
- * level1
- * @param xhr
- * @private
- */
- _applyContentType:function (xhr) {
- //content type is not set in case of xhr level2 because
- //the form data object does it itself
- },
-
- _formDataToURI:function (formData) {
- //in xhr level2 form data takes care of the http get parametrisation
- return "";
- },
-
- _getTransport:function () {
- return new XMLHttpRequest();
- }
-});
-
-/**
- * for normal requests we basically use
- * only the xhr level2 object but
- */
-_MF_CLS(_PFX_XHR + "_AjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, {
-
- _sourceForm:null,
-
- constructor_:function (args) {
- this._callSuper("constructor_", args);
- //TODO xhr level2 can deal with real props
-
- },
-
- _getTransport:function () {
- return new XMLHttpRequest();
- }
-});
-
-
-
-
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
index 493e4d32a..f74dc872c 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
@@ -197,7 +197,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
* JSF 2.3 we set all the viewstates under a given declared viewRoot or all forms
* if none is given
*/
- this._updateJSFClientArtifacts(context, mfInternal.appliedViewState, this.P_VIEWSTATE);
+ this._updateJSFClientArtifacts(context, mfInternal.appliedViewState, this.P_VIEWSTATE);
},
@@ -268,10 +268,10 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
}
},
- _fetchUniqueId: function (prefix, identifier) {
+ _fetchUniqueId: function(prefix, identifier) {
var cnt = 0;
var retVal = prefix + identifier + jsf.separatorchar + cnt;
- while (this._Dom.byId(retVal) != null) {
+ while(this._Dom.byId(retVal) != null) {
cnt++;
retVal = prefix + identifier + jsf.separatorchar + cnt;
}
@@ -308,6 +308,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
}
+
var viewRoot = this._getViewRoot(context);
var forms = this._Dom.findByTagNames(viewRoot, {"form": 1}) || [];
@@ -316,7 +317,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
//to deal with multiple render targets.
- if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) {
+ if(this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) {
//We update all elements under viewroot
//this clearly violates the jsf 2.3 jsdocs
@@ -339,7 +340,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
var viewRootId = viewRoot.id || "";
- for (var cnt = 0; cnt < context._mfInternal._updateForms.length; cnt++) {
+ for(var cnt = 0; cnt < context._mfInternal._updateForms.length; cnt++) {
var updateForm = context._mfInternal._updateForms[cnt];
//follow the spec 2.3 path 1:1 we update the forms hosting the render targets which start
@@ -354,7 +355,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
//(aka fallback into the old behavior)
- if (updateForm.indexOf(viewRootId) != 0) {
+ if(updateForm.indexOf(viewRootId) != 0) {
continue;
} else { //either an empty viewroot, or a namespace match
this._applyJSFArtifactValueToForm(context, this._Dom.byId(updateForm), value, identifier);
@@ -455,6 +456,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
case this.CMD_UPDATE:
this.processUpdate(request, context, changes[i]);
break;
+ //this one needs a csp spec extension for the global eval
+ //for now we recycle the csp for this case from the jsf.js file
case this.CMD_EVAL:
_Lang.globalEval(changes[i].firstChild.data);
break;
@@ -495,7 +498,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
} else if (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) {
mfInternal.appliedClientWindow = node.firstChild.nodeValue;
}
- } else {
+ }
+ else {
// response may contain several blocks
var cDataBlock = this._Dom.concatCDATABlocks(node),
resultNode = null,
@@ -541,30 +545,31 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
return true;
},
- _pushOperationResult: function (context, resultNode) {
+ _pushOperationResult: function(context, resultNode) {
var mfInternal = context._mfInternal;
- var pushSubnode = this._Lang.hitch(this, function (currNode) {
+ var pushSubnode = this._Lang.hitch(this, function(currNode) {
var parentForm = this._Dom.getParent(currNode, "form");
//if possible we work over the ids
//so that elements later replaced are referenced
//at the latest possibility
if (null != parentForm) {
mfInternal._updateForms.push(parentForm.id || parentForm);
- } else {
+ }
+ else {
mfInternal._updateElems.push(currNode.id || currNode);
}
});
- var pushEmbedded = this._Lang.hitch(this, function (currNode) {
- if (currNode.tagName && this._Lang.equalsIgnoreCase(currNode.tagName, "form")) {
- if (currNode.id) { //should not happen but just in case someone manipulates the html
+ var pushEmbedded = this._Lang.hitch(this, function(currNode) {
+ if(currNode.tagName && this._Lang.equalsIgnoreCase(currNode.tagName, "form")) {
+ if(currNode.id) { //should not happen but just in case someone manipulates the html
mfInternal._updateForms.push(currNode.id);
}
} else {
var childForms = this._Dom.findByTagName(currNode, "form");
- if (childForms && childForms.length) {
- for (var cnt = 0; cnt < childForms.length; cnt++) {
- if (childForms[cnt].id) {
+ if(childForms && childForms.length) {
+ for(var cnt = 0; cnt < childForms.length; cnt++) {
+ if(childForms[cnt].id) {
mfInternal._updateForms.push(childForms[cnt].id);
}
}
@@ -600,45 +605,13 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
* @return an xml representation of the page for further processing if possible
*/
_replaceHead: function (request, context, newData) {
- var _Lang = this._Lang,
- _Dom = this._Dom,
- _RT = this._RT,
- isWebkit = this._RT.browser.isWebKit,
- //we have to work around an xml parsing bug in Webkit
- //see https://issues.apache.org/jira/browse/MYFACES-3061
- doc = (!isWebkit) ? _Lang.parseXML(newData) : null,
- newHead = null;
-
- if (!isWebkit && _Lang.isXMLParseError(doc)) {
- doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->"));
- }
-
- if (isWebkit || _Lang.isXMLParseError(doc)) {
- //the standard xml parser failed we retry with the stripper
- var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
- var headData = parser.parse(newData, "head");
- //We cannot avoid it here, but we have reduced the parsing now down to the bare minimum
- //for further processing
- newHead = _Lang.parseXML("<head>" + headData + "</head>");
- //last and slowest option create a new head element and let the browser
- //do its slow job
- if (_Lang.isXMLParseError(newHead)) {
- try {
- newHead = _Dom.createElement("head");
- newHead.innerHTML = headData;
- } catch (e) {
- //we give up no further fallbacks
- throw this._raiseError(new Error(), "Error head replacement failed reason:" + e.toString(), "_replaceHead");
- }
- }
- newHead = newHead.childNodes[0];
- } else {
- //parser worked we go on
- newHead = doc.getElementsByTagName("head")[0];
- }
- var oldTags = _Lang.objToArray(document.head.childNodes);
+ var _Lang = this._Lang,
+ _Dom = this._Dom;
+ var newDom = _Dom.fromMarkup(newData);
+ var newHead = newDom.getElementsByTagName("head")[0];
+ var oldTags = document.head.childNodes;
_Dom.deleteItems(_Lang.objToArray(oldTags));
_Dom.appendToHead(newHead);
@@ -648,7 +621,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
},
_addResourceToHead: function (request, context, newData) {
- this._Dom.appendToHead(newData);
+ this._Dom.appendToHead(newData);
},
/**
@@ -665,61 +638,36 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
_replaceBody: function (request, context, newData /*varargs*/) {
var _RT = this._RT,
_Dom = this._Dom,
- _Lang = this._Lang,
oldBody = document.getElementsByTagName("body")[0],
- placeHolder = document.createElement("div"),
- isWebkit = _RT.browser.isWebKit;
+ placeHolder = document.createElement("div");
placeHolder.id = "myfaces_bodyplaceholder";
+ var newDom = _Dom.fromMarkup(newData);
+ var newBodyData = newDom.getElementsByTagName("body")[0];
+
_Dom._removeChildNodes(oldBody);
oldBody.innerHTML = "";
oldBody.appendChild(placeHolder);
- var bodyData, doc = null, parser;
-
- //we have to work around an xml parsing bug in Webkit
- //see https://issues.apache.org/jira/browse/MYFACES-3061
- if (!isWebkit) {
- doc = (arguments.length > 3) ? arguments[3] : _Lang.parseXML(newData);
- }
-
- if (!isWebkit && _Lang.isXMLParseError(doc)) {
- doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->"));
- }
-
- if (isWebkit || _Lang.isXMLParseError(doc)) {
- //the standard xml parser failed we retry with the stripper
- parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
-
- bodyData = parser.parse(newData, "body");
- } else {
- //parser worked we go on
- var newBodyData = doc.getElementsByTagName("body")[0];
-
- //speedwise we serialize back into the code
- //for code reduction, speedwise we will take a small hit
- //there which we will clean up in the future, but for now
- //this is ok, I guess, since replace body only is a small subcase
- //bodyData = _Lang.serializeChilds(newBodyData);
- var browser = _RT.browser;
- if (!browser.isIEMobile || browser.isIEMobile >= 7) {
- //TODO check what is failing there
- for (var cnt = 0; cnt < newBodyData.attributes.length; cnt++) {
- var value = newBodyData.attributes[cnt].value;
- if (value)
- _Dom.setAttribute(oldBody, newBodyData.attributes[cnt].name, value);
- }
+ //speedwise we serialize back into the code
+ //for code reduction, speedwise we will take a small hit
+ //there which we will clean up in the future, but for now
+ //this is ok, I guess, since replace body only is a small subcase
+ //bodyData = _Lang.serializeChilds(newBodyData);
+ var browser = _RT.browser;
+ if (!browser.isIEMobile || browser.isIEMobile >= 7) {
+ //TODO check what is failing there
+ for (var cnt = 0; cnt < newBodyData.attributes.length; cnt++) {
+ var value = newBodyData.attributes[cnt].value;
+ if (value)
+ _Dom.setAttribute(oldBody, newBodyData.attributes[cnt].name, value);
}
}
- //we cannot serialize here, due to escape problems
- //we must parse, this is somewhat unsafe but should be safe enough
- parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
- bodyData = parser.parse(newData, "body");
- var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData);
+ var returnedElement = this.replaceHtmlItem(request, context, placeHolder, newBodyData.innerHTML);
if (returnedElement) {
this._pushOperationResult(context, returnedElement);
@@ -939,6 +887,6 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
var finalName = name || _Impl.MALFORMEDXML;
var finalMessage = message || "";
- return this._Lang.makeException(error, finalTitle, finalName, this._nameSpace, caller || ((arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
+ return this._Lang.makeException(error, finalTitle, finalName, this._nameSpace, caller || ( (arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
}
});
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_ExtAjaxRequest.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_FormDataRequest.js
similarity index 70%
rename from api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_ExtAjaxRequest.js
rename to api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_FormDataRequest.js
index 185e0de32..7978a5457 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_ExtAjaxRequest.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_FormDataRequest.js
@@ -13,20 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
- * Extendend functionality
- * like issuing element outside of a form
- * and partial page submit
- *
- * Author: Werner Punz (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
+ * this method is used only for pure multipart form parts
+ * like form data with file uploads.
+ * This is a replacement for the iframe request which we used until now
+ * The iframe method works on older browsers but most likely will
+ * be cut off in future browsers, because there is an alternative
+ * in form of FormData.
*/
+_MF_CLS(_PFX_XHR+"_FormDataRequest", myfaces._impl.xhrCore._AjaxRequest, {
+ _AJAXUTIL: myfaces._impl.xhrCore._AjaxUtils,
+
+ constructor_: function(arguments) {
+ this._callSuper("constructor_", arguments);
-//partial extension for the ajax request
-myfaces._impl.xhrCore._AjaxRequest = _MF_CLS(_PFX_XHR + "_ExtAjaxRequest", myfaces._impl.xhrCore._AjaxRequest , /** @lends myfaces._impl.xhrCore._ExtAjaxRequest.prototype */ {
- constructor_: function(args) {
- this._callSuper("constructor_", args);
+ this._contentType = "multipart/form-data";
},
/**
@@ -41,22 +42,33 @@ myfaces._impl.xhrCore._AjaxRequest = _MF_CLS(_PFX_XHR + "_ExtAjaxRequest", myfac
getFormData : function() {
var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces, ret = null;
+
//now this is less performant but we have to call it to allow viewstate decoration
if (!this._partialIdsArray || !this._partialIdsArray.length) {
- ret = this._callSuper("getFormData");
+ ret = new FormData();
+ _AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm);
//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 && myfacesOptions && myfacesOptions.form)
_AJAXUTIL.appendIssuingItem(this._source, ret);
} else {
- ret = this._Lang.createFormDataDecorator(new Array());
+ ret = new FormData();
_AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, this._partialIdsArray);
if (this._source && myfacesOptions && myfacesOptions.form)
_AJAXUTIL.appendIssuingItem(this._source, ret);
}
+
return ret;
+ },
+
+ _getTransport: function() {
+ return new XMLHttpRequest();
+ },
+
+ _applyContentType: function(xhr) {
+
}
-});
+});
\ No newline at end of file
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
index 6a8f0ac82..300170459 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
@@ -40,150 +40,257 @@
* corresponding protected attributes on class level in the transports themselves)
*/
_MF_SINGLTN(_PFX_XHR + "_Transports", _MF_OBJECT,
- /** @lends myfaces._impl.xhrCore._Transports.prototype */ {
-
- _PAR_ERRORLEVEL:"errorlevel",
- _PAR_QUEUESIZE:"queuesize",
- _PAR_PPS:"pps",
- _PAR_TIMEOUT:"timeout",
- _PAR_DELAY:"delay",
-
-
- /**
- * a singleton queue
- * note the structure of our inheritance
- * is that that _queue is attached to prototype
- * and hence the pointer to the request qeue
- * is shared over all instances
- *
- * if you need to have it per instance for complex objects
- * you have to initialize in the constructor
- *
- * (This is the same limitation dojo class inheritance
- * where our inheritance pattern is derived from has)
- */
- _q: new myfaces._impl.xhrCore._AjaxRequestQueue(),
-
- /**
- * xhr post with enqueuing as defined by the jsf 2.0 specification
- *
- * mapped options already have the exec and view properly in place
- * myfaces specifics can be found under mappedOptions.myFaces
- * @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} passThrgh (Map) values to be passed through
- **/
- xhrQueuedPost : function(source, sourceForm, context, passThrgh) {
- context._mfInternal.xhrOp = "xhrQueuedPost";
- this._q.enqueue(
+ /** @lends myfaces._impl.xhrCore._Transports.prototype */ {
+
+ _PAR_ERRORLEVEL: "errorlevel",
+ _PAR_QUEUESIZE: "queuesize",
+ _PAR_PPS: "pps",
+ _PAR_TIMEOUT: "timeout",
+ _PAR_DELAY: "delay",
+
+
+ /**
+ * a singleton queue
+ * note the structure of our inheritance
+ * is that that _queue is attached to prototype
+ * and hence the pointer to the request qeue
+ * is shared over all instances
+ *
+ * if you need to have it per instance for complex objects
+ * you have to initialize in the constructor
+ *
+ * (This is the same limitation dojo class inheritance
+ * where our inheritance pattern is derived from has)
+ */
+ _q: new myfaces._impl.xhrCore._AjaxRequestQueue(),
+
+ /**
+ * xhr post with enqueuing as defined by the jsf 2.0 specification
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ xhrQueuedPost: function (source, sourceForm, context, passThrgh) {
+ this._q.enqueue(
new (this._getAjaxReqClass(context))(this._getArguments(source, sourceForm, context, passThrgh)));
- },
-
- /**
- * iframe queued post
- *
- * mapped options already have the exec and view properly in place
- * myfaces specifics can be found under mappedOptions.myFaces
- * @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} passThrgh (Map) values to be passed through
- **/
- multipartQueuedPost : function(source, sourceForm, context, passThrgh) {
- context._mfInternal.xhrOp = "multipartQueuedPost";
- var args = this._getArguments(source, sourceForm, context, passThrgh);
- // note in get the timeout is not working delay however is and queue size as well
- // since there are no cross browser ways to resolve a timeout on xhr level
- this._q.enqueue(
- new (this._getMultipartReqClass(context))(args));
- },
-
-
- /**
- * creates the arguments map and
- * fetches the config params in a proper way in to
- * deal with them in a flat way (from the nested context way)
- *
- * @param source the source of the request
- * @param sourceForm the sourceform
- * @param context the context holding all values
- * @param passThrgh the passThrough values to be blended into the response
- */
- _getArguments: function(source, sourceForm, context, passThrgh) {
- var _RT = myfaces._impl.core._Runtime,
- /** @ignore */
- _Lang = myfaces._impl._util._Lang,
- applyCfg = _Lang.hitch(this, this._applyConfig),
- //RT does not have this references, hence no hitch needed
- getCfg = _RT.getLocalOrGlobalConfig,
-
-
- ret = {
- "source": source,
- "sourceForm": sourceForm,
- "context": context,
- "passThrough": passThrgh,
- "xhrQueue": this._q
- };
-
- //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
- applyCfg(ret, context, "alarmThreshold", this._PAR_ERRORLEVEL);
- applyCfg(ret, context, "queueSize", this._PAR_QUEUESIZE);
- //TODO timeout probably not needed anymore
- applyCfg(ret, context, "timeout", this._PAR_TIMEOUT);
- //applyCfg(ret, context, "delay", this._PAR_DELAY);
-
- //now partial page submit needs a different treatment
- //since pps == execute strings
- if (getCfg(context, this._PAR_PPS, false)
+ },
+
+
+ /**
+ * a simple not enqueued xhr post
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ xhrPost: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ delete args.xhrQueue;
+ (new (this._getAjaxReqClass(context))(args)).send();
+ },
+
+
+ /**
+ * xhr get without enqueuing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ xhrGet: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ delete args.xhrQueue;
+ (new (this._getAjaxReqClass(context))(args)).send();
+ },
+
+ /**
+ * xhr get which takes the existing queue into consideration to by synchronized
+ * to previous queued post requests
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ xhrQueuedGet: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ this._q.enqueue(
+ new (this._getAjaxReqClass(context))(args));
+ },
+
+
+ /**
+ * multipart post without queueing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ multipartPost: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ delete args.xhrQueue;
+ (new (this._getMultipartReqClass(context))(args)).send();
+ },
+
+ /**
+ * multipart queued post
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ multipartQueuedPost: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ this._q.enqueue(
+ new (this._getMultipartReqClass(context))(args));
+ },
+
+ /**
+ * iframe get without queueing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ multipartGet: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ delete args.xhrQueue;
+ (new (this._getMultipartReqClass(context))(args)).send();
+ },
+
+ /**
+ * multipart queued http get
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @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} passThrgh (Map) values to be passed through
+ **/
+ multipartQueuedGet: function (source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ args.ajaxType = "GET";
+ this._q.enqueue(
+ new (this._getMultipartReqClass(context))(args));
+ },
+
+
+ /**
+ * creates the arguments map and
+ * fetches the config params in a proper way in to
+ * deal with them in a flat way (from the nested context way)
+ *
+ * @param source the source of the request
+ * @param sourceForm the sourceform
+ * @param context the context holding all values
+ * @param passThrgh the passThrough values to be blended into the response
+ */
+ _getArguments: function (source, sourceForm, context, passThrgh) {
+ var _RT = myfaces._impl.core._Runtime,
+ /** @ignore */
+ _Lang = myfaces._impl._util._Lang,
+ applyCfg = _Lang.hitch(this, this._applyConfig),
+ //RT does not have this references, hence no hitch needed
+ getCfg = _RT.getLocalOrGlobalConfig,
+
+
+ ret = {
+ "source": source,
+ "sourceForm": sourceForm,
+ "context": context,
+ "passThrough": passThrgh,
+ "xhrQueue": this._q
+ };
+
+ //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
+ applyCfg(ret, context, "alarmThreshold", this._PAR_ERRORLEVEL);
+ applyCfg(ret, context, "queueSize", this._PAR_QUEUESIZE);
+ //TODO timeout probably not needed anymore
+ applyCfg(ret, context, "timeout", this._PAR_TIMEOUT);
+ //applyCfg(ret, context, "delay", this._PAR_DELAY);
+
+ //now partial page submit needs a different treatment
+ //since pps == execute strings
+ if (getCfg(context, this._PAR_PPS, false)
&& _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 ret;
- },
-
- /**
- * helper method to apply a config setting to our varargs param list
- *
- * @param destination the destination map to receive the setting
- * @param context the current context
- * @param destParm the destination param of the destination map
- * @param srcParm the source param which is the key to our config setting
- */
- _applyConfig: function(destination, context, destParm, srcParm) {
- var _RT = myfaces._impl.core._Runtime;
- /** @ignore */
- var _getConfig = _RT.getLocalOrGlobalConfig;
- if (_getConfig(context, srcParm, null) != null) {
- destination[destParm] = _getConfig(context, srcParm, null);
- }
- },
-
- /**
- * centralized transport switching helper
- * for the multipart submit case
- *
- * @param context the context which is passed down
- */
- _getMultipartReqClass: function(context) {
- if (this._RT.getXHRLvl() >= 2) {
- return myfaces._impl.xhrCore._MultipartAjaxRequestLevel2;
- } else {
- return myfaces._impl.xhrCore._IFrameRequest;
- }
- },
-
-
- _getAjaxReqClass: function(context) {
- // var _RT = myfaces._impl.core._Runtime;
- if(this._RT.getXHRLvl() < 2) {
- return myfaces._impl.xhrCore._AjaxRequest;
- } else {
- return myfaces._impl.xhrCore._AjaxRequestLevel2;
+ ret['partialIdsArray'] = passThrgh[myfaces._impl.core.Impl.P_EXECUTE].split(" ");
+ }
+ return ret;
+ },
+
+ /**
+ * helper method to apply a config setting to our varargs param list
+ *
+ * @param destination the destination map to receive the setting
+ * @param context the current context
+ * @param destParm the destination param of the destination map
+ * @param srcParm the source param which is the key to our config setting
+ */
+ _applyConfig: function (destination, context, destParm, srcParm) {
+ var _RT = myfaces._impl.core._Runtime;
+ /** @ignore */
+ var _getConfig = _RT.getLocalOrGlobalConfig;
+ if (_getConfig(context, srcParm, null) != null) {
+ destination[destParm] = _getConfig(context, srcParm, null);
+ }
+ },
+
+ /**
+ * centralized transport switching helper
+ * for the multipart submit case
+ *
+ * @param context the context which is passed down
+ */
+ _getMultipartReqClass: function (context) {
+ return myfaces._impl.xhrCore._FormDataRequest;
+ },
+
+
+ _getAjaxReqClass: function (context) {
+ return myfaces._impl.xhrCore._AjaxRequest;
}
- }
-});
+ });
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js b/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
index 8eceb1fe2..e7d77b96e 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
@@ -356,7 +356,7 @@ if (!jsf.push) {
}
// Public static functions ----------------------------------------------------------------------------------------
-
+ var _t = this;
/**
*
* @param {function} onopen The function to be invoked when the web socket is opened.
@@ -394,7 +394,7 @@ if (!jsf.push) {
}
if (autoconnect) {
- this.open(socketClientId);
+ _t.open(socketClientId);
}
}