You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ga...@apache.org on 2009/06/20 20:45:29 UTC
svn commit: r786880 - in
/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl:
_util/_Utils.js xhrCore/_AjaxRequest.js xhrCore/_AjaxResponse.js
xhrCore/_AjaxUtils.js
Author: ganesh
Date: Sat Jun 20 18:45:29 2009
New Revision: 786880
URL: http://svn.apache.org/viewvc?rev=786880&view=rev
Log:
MYFACES-2257
Modified:
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=786880&r1=786879&r2=786880&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Sat Jun 20 18:45:29 2009
@@ -94,7 +94,65 @@
}
};
-
+
+ /**
+ * encapsulated xhr object which tracks down various implementations
+ * of the xhr object in a browser independend fashion
+ * (ie pre 7 used to have non standard implementations because
+ * the xhr object standard came after IE had implemented it first
+ * newer ie versions adhere to the standard and all other new browsers do anyway)
+ */
+ myfaces._impl._util._Utils.getXHRObject = function() {
+ if('undefined' != typeof XMLHttpRequest && null != XMLHttpRequest) {
+ return new XMLHttpRequest();
+ }
+ //IE
+ try {
+ return new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+
+ }
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ }
+
+ /**
+ * [STATIC]
+ * loads a script and executes it under a global scope
+ * @param {String} src the source to be loaded
+ * @param {String} type the mime type of the script (currently ignored
+ * but in the long run it will be used)
+ */
+ myfaces._impl._util._Utils.loadScript = function(src, type, defer, charSet) {
+ var xhr = myfaces._impl._util._Utils.getXHRObject();
+ xhr.open("GET", src, false);
+
+ if('undefined' != typeof charSet && null != charSet) {
+ xhr.setRequestHeader("Content-Type","application/x-javascript; charset:"+charSet);
+ }
+
+ xhr.send(null);
+
+ //since we are synchronous we do it after not with onReadyStateChange
+ if(xhr.readyState == 4) {
+ if (xhr.status == 200) {
+ //defer also means we have to process after the ajax response
+ //has been processed
+ //we can achieve that with a small timeout, the timeout
+ //triggers after the processing is done!
+ if(!defer) {
+ myfaces._impl._util._Utils.globalEval(xhr.responseText);
+ } else {
+ setTimeout(function() {
+ myfaces._impl._util._Utils.globalEval(xhr.responseText);
+ },1);
+ }
+ } else {
+ throw Error(xhr.responseText);
+ }
+ } else {
+ throw Error("Loading of script "+src+" failed ");
+ }
+ }
/**
* [STATIC]
@@ -108,25 +166,33 @@
if (item.nodeType == 1) { // only if it's an element node
if (item.tagName.toLowerCase() == 'script') {
try {
- var test = item.text;
- var go = true;
- while (go) {
- go = false;
- if (test.substring(0, 1) == " ") {
- test = test.substring(1);
- go = true;
- }
- if (test.substring(0, 4) == "<!--") {
- test = test.substring(4);
- go = true;
- }
- if (test.substring(0, 11) == "//<![CDATA[") {
- test = test.substring(11);
- go = true;
- }
- }
- /*we have to run the script under a global context*/
- myfaces._impl._util._Utils.globalEval(test); // run the script
+ if (typeof item.getAttribute('src') != 'undefined'
+ && item.getAttribute('src') != null
+ && item.getAttribute('src').length > 0 ) {
+ // external script auto eval
+ myfaces._impl._util._Utils.loadScript(item.getAttribute('src'), item.getAttribute('type'), false, "ISO-8859-1");
+ } else {
+ // embedded script auto eval
+ var test = item.text;
+ var go = true;
+ while (go) {
+ go = false;
+ if (test.substring(0, 1) == " ") {
+ test = test.substring(1);
+ go = true;
+ }
+ if (test.substring(0, 4) == "<!--") {
+ test = test.substring(4);
+ go = true;
+ }
+ if (test.substring(0, 11) == "//<![CDATA[") {
+ test = test.substring(11);
+ go = true;
+ }
+ }
+ // we have to run the script under a global context
+ myfaces._impl._util._Utils.globalEval(test); // run the script
+ }
} catch (e) {
myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "runScripts", e);
}
@@ -196,7 +262,6 @@
}
};
-
myfaces._impl._util._Utils.ieQuircksEvents = {
"onabort": true,
"onload":true,
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=786880&r1=786879&r2=786880&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Sat Jun 20 18:45:29 2009
@@ -82,7 +82,7 @@
*/
myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
try {
- this.m_xhr = this.m_ajaxUtil.getXHRObject();
+ this.m_xhr = myfaces._impl._util._Utils.getXHRObject();
this.m_xhr.open("POST", this.m_sourceForm.action, true);
this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=786880&r1=786879&r2=786880&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Sat Jun 20 18:45:29 2009
@@ -279,13 +279,6 @@
myfaces._impl.xhrCore._AjaxResponse.prototype._replaceElement = function(request, context, oldElement, newData) {
myfaces._impl._util._Utils.replaceHtmlItem(request, context,
oldElement, newData, this.m_htmlFormElement);
- //fetch the scripts and do an eval on the scripts to bypass
- //browser inconsistencies in this area
- //lets have the browser itself deal with this issue, j4fry
- //is pretty well optimized in this area!
- if (myfaces._impl._util._Utils.isManualScriptEval()) {
- myfaces._impl._util._Utils.runScripts(request, context, newData);
- }
};
/*insert, three attributes can be present
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=786880&r1=786879&r2=786880&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Sat Jun 20 18:45:29 2009
@@ -117,67 +117,6 @@
}
/**
- * encapsulated xhr object which tracks down various implementations
- * of the xhr object in a browser independend fashion
- * (ie pre 7 used to have non standard implementations because
- * the xhr object standard came after IE had implemented it first
- * newer ie versions adhere to the standard and all other new browsers do anyway)
- */
- myfaces._impl.xhrCore._AjaxUtils.prototype.getXHRObject = function() {
- if('undefined' != typeof XMLHttpRequest && null != XMLHttpRequest) {
- return new XMLHttpRequest();
- }
- //IE
- try {
- return new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
-
- }
- return new ActiveXObject('Microsoft.XMLHTTP');
- }
-
-
- /**
- * loads a script and executes it under a global scope
- * @param {String} src the source to be loaded
- * @param {String} type the mime type of the script (currently ignored
- * but in the long run it will be used)
- */
- myfaces._impl.xhrCore._AjaxUtils.prototype.loadScript = function(src, type, defer, charSet) {
- var xhr = this.getXHRObject();
- xhr.open("GET", src, false);
-
- if('undefined' != typeof charSet && null != charSet) {
- xhr.setRequestHeader("Content-Type","application/x-javascript; charset:"+charSet);
- }
-
- xhr.send(null);
-
- //since we are synchronous we do it after not with onReadyStateChange
- if(xhr.readyState == 4) {
- if (xhr.status == 200) {
- //defer also means we have to process after the ajax response
- //has been processed
- //we can achieve that with a small timeout, the timeout
- //triggers after the processing is done!
- if(!defer) {
- myfaces._impl._util._Utils.globalEval(xhr.responseText);
- } else {
- setTimeout(function() {
- myfaces._impl._util._Utils.globalEval(xhr.responseText);
- },1);
- }
- } else {
- throw Error(xhr.responseText);
- }
- } else {
- throw Error("Loading of script "+src+" failed ");
- }
- }
-
-
-
- /**
* add a single field to stringbuffer for param submission
* @param {HtmlElement} element -
* @param {} stringBuffer -