You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/05/21 12:51:21 UTC
svn commit: r946969 [2/3] - in
/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces:
_impl/_util/ _impl/core/ _impl/xhrCore/ api/
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Fri May 21 10:51:20 2010
@@ -30,524 +30,530 @@
*
*
*/
-if ('undefined' == typeof myfaces || myfaces == null) {
- /**
- * A simple provide function
- * fixing the namespaces
- */
- /*originally we had it at org.apache.myfaces, but we are now down to myfaces since the openajax seems to have problems registering more than a root domain and org is not only apache specific*/
- myfaces = new Object();
-}
-
-if ('undefined' == typeof(myfaces._impl) || null == myfaces._impl) {
- myfaces._impl = new Object();
-}
-
-if ('undefined' == typeof(myfaces._impl.core) || null == myfaces._impl.core) {
- myfaces._impl.core = new Object();
-}
+/** @namespace myfaces._impl.core._Runtime*/
+(!window.myfaces) ? window.myfaces = {} : null;
+(!myfaces._impl) ? myfaces._impl = {} : null;
+(!myfaces._impl.core) ? myfaces._impl.core = {} : null;
//now this is the only time we have to do this cascaded and manually
//for the rest of the classes our reserveNamespace function will do the trick
-if ('undefined' == typeof myfaces._impl.core._Runtime || myfaces._impl.core._Runtime == null) {
- myfaces._impl.core._Runtime = new Object();
- //the rest of the namespaces can be handled by our namespace feature
-
- /**
- * global eval on scripts
- *
- * usage return myfaces._impl.core._Runtime.globalEval('myvar.myvar2;');
- *
- */
- myfaces._impl.core._Runtime.globalEval = function(code) {
- //chrome as a diferent global eval, thanks for pointing this out
- //TODO add a config param which allows to evaluate global scripts even if the call
- //is embedded in an iframe
- if (myfaces._impl.core._Runtime.browser.isIE && window.execScript) {
- //execScript definitely only for IE otherwise we might have a custom
- //window extension with undefined behavior on our necks
- return window.execScript(code);
-
- } else if (undefined != typeof (window.eval) && null != window.eval) {
-
- //fix for a Mozilla bug, Mozilla prevents, that the window is properly applied
- //the former approach was to scope an outer anonymous function but the scoping is not necessary
- //Mozilla behaves correctly if you just add an outer function, then the window scope is again
- //accepted as the real scope
- var func = function () {
- return window.eval.call(window, code);
- };
- return func();
- }
- //we probably have covered all browsers, but this is a safety net which might be triggered
- //by some foreign browser which is not covered by the above cases
- return eval.call(window, code);
- };
+if (!myfaces._impl.core._Runtime) {
+ myfaces._impl.core._Runtime = new function() {
+ //the rest of the namespaces can be handled by our namespace feature
+ //helper to avoid unneeded hitches
+ var _this = this;
+ /**
+ * global eval on scripts
+ *
+ * usage return this.globalEval('myvar.myvar2;');
+ *
+ */
+ this.globalEval = function(code) {
+ //chrome as a diferent global eval, thanks for pointing this out
+ //TODO add a config param which allows to evaluate global scripts even if the call
+ //is embedded in an iframe
+ if (_this.browser.isIE && window.execScript) {
+ //execScript definitely only for IE otherwise we might have a custom
+ //window extension with undefined behavior on our necks
+ return window.execScript(code);
+
+ } else if (window.eval) {
+
+ //fix for a Mozilla bug, Mozilla prevents, that the window is properly applied
+ //the former approach was to scope an outer anonymous function but the scoping is not necessary
+ //Mozilla behaves correctly if you just add an outer function, then the window scope is again
+ //accepted as the real scope
+ var func = function () {
+ return window.eval.call(window, code);
+ };
+ return func();
+ }
+ //we probably have covered all browsers, but this is a safety net which might be triggered
+ //by some foreign browser which is not covered by the above cases
+ return eval.call(window, code);
+ };
- /**
- * applies an object to a namespace
- * basically does what bla.my.name.space = obj does
- * note we cannot use var myNameSpace = fetchNamespace("my.name.space")
- * myNameSpace = obj because the result of fetch is already the object
- * which the namespace points to, hence this function
- *
- * @param nameSpace the namespace to be assigned to
- * @param obj the object to be assigned
- */
- myfaces._impl.core._Runtime.applyToGlobalNamespace = function(nameSpace, obj) {
- var splittedNamespace = nameSpace.split(/\./);
- if (splittedNamespace.length == 1) {
- window[namespace] = obj;
- return null;
- }
- var parent = splittedNamespace.slice(0, splittedNamespace.length - 1);
- var child = splittedNamespace[splittedNamespace.length - 1];
- var parentNamespace = myfaces._impl.core._Runtime.fetchNamespace(parent.join("."));
- parentNamespace[child] = obj;
- };
+ /**
+ * applies an object to a namespace
+ * basically does what bla.my.name.space = obj does
+ * note we cannot use var myNameSpace = fetchNamespace("my.name.space")
+ * myNameSpace = obj because the result of fetch is already the object
+ * which the namespace points to, hence this function
+ *
+ * @param nms the namespace to be assigned to
+ * @param obj the object to be assigned
+ */
+ this.applyToGlobalNamespace = function(nms, obj) {
+ var splitted = nms.split(/\./);
+ if (splitted.length == 1) {
+ window[namespace] = obj;
+ return;
+ }
+ var parent = splitted.slice(0, splitted.length - 1);
+ var child = splitted[splitted.length - 1];
+ var parentNamespace = _this.fetchNamespace(parent.join("."));
+ parentNamespace[child] = obj;
+ };
- /**
- * fetches the object the namespace points to
- * @param nameSpace the namespace which has to be fetched
- * @return the object the namespace points to or null if nothing is found
- */
- myfaces._impl.core._Runtime.fetchNamespace = function(nameSpace) {
- try {
- var origNamespace = nameSpace;
- nameSpace = myfaces._impl.core._Runtime.globalEval("window." + nameSpace);
- if ('undefined' == typeof nameSpace || null == nameSpace) {
- //ie in any version does not like that particularily
- //we do it the hard way now
- nameSpace = origNamespace.split(/\./);
- var currentElem = window;
- var namespaceLen = nameSpace.length;
-
- for (var cnt = 0; cnt < namespaceLen; cnt++) {
- currentElem = currentElem[nameSpace[cnt]];
- if ('undefined' == typeof currentElem || null == currentElem) {
- return null;
- }
- }
- return currentElem;
+ /**
+ * fetches the object the namespace points to
+ * @param nms the namespace which has to be fetched
+ * @return the object the namespace points to or null if nothing is found
+ */
+ this.fetchNamespace = function(nms) {
+ if ('undefined' == typeof nms || null == nms) {
+ return null;
}
- return nameSpace;
- } catch (e) {/*wanted*/
- }
- return null;
- };
- /**
- * Backported from dojo
- * a failsafe string determination method
- * (since in javascript String != "" typeof alone fails!)
- * @param it {|Object|} the object to be checked for being a string
- * @return true in case of being a string false otherwiseÊ
- */
- myfaces._impl.core._Runtime.isString = function(/*anything*/ it) {
- // summary:
- // Return true if it is a String
- return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
- };
+ var ret = null;
+ try {
+ ret = _this.globalEval("window." + nms);
+ //namespace could point to numeric or boolean hence full
+ //save check
- /**
- * reserves a namespace in the specific scope
- *
- * usage:
- * if(myfaces._impl.core._Runtime.reserve("org.apache.myfaces.MyUtils")) {
- * org.apache.myfaces.MyUtils = function() {
- * }
- * }
- *
- * reserves a namespace and if the namespace is new the function itself is reserved
- *
- *
- *
- * or:
- * myfaces._impl.core._Runtime.reserve("org.apache.myfaces.MyUtils", function() { .. });
- *
- * reserves a namespace and if not already registered directly applies the function the namespace
- *
- * @param {|String|} nameSpace
- * @returns true if it was not provided
- * false otherwise for further action
- */
- myfaces._impl.core._Runtime.reserveNamespace = function(nameSpace, reservationFunction) {
- var _RT = myfaces._impl.core._Runtime;
- if (!_RT.isString(nameSpace)) {
- throw Error("Namespace must be a string with . as delimiter");
- }
- if (null != _RT.fetchNamespace(nameSpace)) {
- return false;
- }
- var namespaceEntries = nameSpace.split(/\./);
- var currentNamespace = window;
- for (var cnt = 0; cnt < namespaceEntries.length; cnt++) {
- var subNamespace = namespaceEntries[cnt];
- if ('undefined' == typeof currentNamespace[subNamespace]) {
- currentNamespace[subNamespace] = {};
+ } catch (e) {/*wanted*/
+ }
+ //ie fallback path because it cannot eval namespaces
+ //ie in any version does not like that particularily
+ //we do it the hard way now
+ if ('undefined' != typeof ret || null != ret) {
+ return ret;
}
- if (cnt == namespaceEntries.length - 1 && 'undefined' != typeof reservationFunction && null != reservationFunction) {
- currentNamespace[subNamespace] = reservationFunction;
+ nms = nms.split(/\./);
+ ret = window;
+ var len = nms.length;
+
+ for (var cnt = 0; cnt < len; cnt++) {
+ ret = ret[nms[cnt]];
+ if ('undefined' == typeof ret || null == ret) {
+ return null;
+ }
}
- currentNamespace = currentNamespace[subNamespace];
- }
+ return ret;
- return true;
- };
+ };
- myfaces._impl.core._Runtime.browserDetection = function() {
/**
- * browser detection code
- * cross ported from dojo 1.2
+ * Backported from dojo
+ * a failsafe string determination method
+ * (since in javascript String != "" typeof alone fails!)
+ * @param it {|Object|} the object to be checked for being a string
+ * @return true in case of being a string false otherwiseÊ
+ */
+ this.isString = function(/*anything*/ it) {
+ // summary:
+ // Return true if it is a String
+ return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
+ };
+
+ /**
+ * reserves a namespace in the specific scope
*
- * dojos browser detection code is very sophisticated
- * hence we port it over it allows a very fine grained detection of
- * browsers including the version number
- * this however only can work out if the user
- * does not alter the user agent, which they normally dont!
- *
- * the exception is the ie detection which relies on specific quirks in ie
- */
- var n = navigator;
- var dua = n.userAgent,
- dav = n.appVersion,
- tv = parseFloat(dav);
-
- myfaces._impl.core._Runtime.browser = {};
- var d = myfaces._impl.core._Runtime.browser;
-
- if (dua.indexOf("Opera") >= 0) {
- myfaces._impl.core._Runtime.isOpera = tv;
- }
- if (dua.indexOf("AdobeAIR") >= 0) {
- d.isAIR = 1;
- }
- d.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : 0;
- d.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined;
- d.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined;
-
- // safari detection derived from:
- // http://developer.apple.com/internet/safari/faq.html#anchor2
- // http://developer.apple.com/internet/safari/uamatrix.html
- var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);
- if (index && !d.isChrome) {
- // try to grab the explicit Safari version first. If we don't get
- // one, look for less than 419.3 as the indication that we're on something
- // "Safari 2-ish".
- d.isSafari = parseFloat(dav.split("Version/")[1]);
- if (!d.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3) {
- d.isSafari = 2;
- }
- }
-
- //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
- if (dua.indexOf("Gecko") >= 0 && !d.isKhtml && !d.isWebKit) {
- d.isMozilla = d.isMoz = tv;
- }
- if (d.isMoz) {
- //We really need to get away from this. Consider a sane isGecko approach for the future.
- d.isFF = parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1] || dua.split("Shiretoko/")[1]) || undefined;
- }
- if (document.all && !d.isOpera) {
- d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
- //In cases where the page has an HTTP header or META tag with
- //X-UA-Compatible, then it is in emulation mode, for a previous
- //version. Make sure isIE reflects the desired version.
- //document.documentMode of 5 means quirks mode.
- if (d.isIE >= 8 && document.documentMode != 5) {
- d.isIE = document.documentMode;
- }
- }
- };
+ * usage:
+ * if(this.reserve("org.apache.myfaces.MyUtils")) {
+ * org.apache.myfaces.MyUtils = function() {
+ * }
+ * }
+ *
+ * reserves a namespace and if the namespace is new the function itself is reserved
+ *
+ *
+ *
+ * or:
+ * this.reserve("org.apache.myfaces.MyUtils", function() { .. });
+ *
+ * reserves a namespace and if not already registered directly applies the function the namespace
+ *
+ * @param {|String|} nms
+ * @returns true if it was not provided
+ * false otherwise for further action
+ */
+ this.reserveNamespace = function(nms, obj) {
- /**
- * fetches a global config entry
- * @param {String} configName the name of the configuration entry
- * @param {Object} defaultValue
- *
- * @return either the config entry or if none is given the default value
- */
- myfaces._impl.core._Runtime.getGlobalConfig = function(configName, defaultValue) {
- /*use(myfaces._impl._util)*/
- var _RT = myfaces._impl.core._Runtime;
-
- if (_RT.exists(myfaces, "config") && _RT.exists(myfaces.config, configName)) {
- return myfaces.config[configName];
- }
- return defaultValue;
- };
+ if (!_this.isString(nms)) {
+ throw Error("Namespace must be a string with . as delimiter");
+ }
+ if (null != _this.fetchNamespace(nms)) {
+ return false;
+ }
+ var entries = nms.split(/\./);
+ var currNms = window;
+ for (var cnt = 0; cnt < entries.length; cnt++) {
+ var subNamespace = entries[cnt];
+ if ('undefined' == typeof currNms[subNamespace]) {
+ currNms[subNamespace] = {};
+ }
+ if (cnt == entries.length - 1 && obj) {
+ currNms[subNamespace] = obj;
+ }
+ currNms = currNms[subNamespace];
+ }
- /**
- * check if an element exists in the root
- */
- myfaces._impl.core._Runtime.exists = function(root, name) {
- if ('undefined' == typeof root || null == root) {
- return false;
- }
-
- //initial condition root set element not set or null
- //equals to element exists
- if ('undefined' == typeof name || null == name) {
return true;
- }
- //crossported from the dojo toolkit
- // summary: determine if an object supports a given method
- // description: useful for longer api chains where you have to test each object in the chain
- var p = name.split(".");
- var len = p.length;
- for (var i = 0; i < len; i++) {
- //the original dojo code here was false because
- //they were testing against ! which bombs out on exists
- //which has a value set to false
- // (TODO send in a bugreport to the Dojo people)
+ };
+
+ this.browserDetection = function() {
+ /**
+ * browser detection code
+ * cross ported from dojo 1.2
+ *
+ * dojos browser detection code is very sophisticated
+ * hence we port it over it allows a very fine grained detection of
+ * browsers including the version number
+ * this however only can work out if the user
+ * does not alter the user agent, which they normally dont!
+ *
+ * the exception is the ie detection which relies on specific quirks in ie
+ */
+ var n = navigator;
+ var dua = n.userAgent,
+ dav = n.appVersion,
+ tv = parseFloat(dav);
+
+ _this.browser = {};
+ var d = _this.browser;
+
+ if (dua.indexOf("Opera") >= 0) {
+ _this.isOpera = tv;
+ }
+ if (dua.indexOf("AdobeAIR") >= 0) {
+ d.isAIR = 1;
+ }
+ d.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : 0;
+ d.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined;
+ d.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined;
+
+ // safari detection derived from:
+ // http://developer.apple.com/internet/safari/faq.html#anchor2
+ // http://developer.apple.com/internet/safari/uamatrix.html
+ var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);
+ if (index && !d.isChrome) {
+ // try to grab the explicit Safari version first. If we don't get
+ // one, look for less than 419.3 as the indication that we're on something
+ // "Safari 2-ish".
+ d.isSafari = parseFloat(dav.split("Version/")[1]);
+ if (!d.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3) {
+ d.isSafari = 2;
+ }
+ }
- if ('undefined' == typeof root[p[i]]) {
+ //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
+ if (dua.indexOf("Gecko") >= 0 && !d.isKhtml && !d.isWebKit) {
+ d.isMozilla = d.isMoz = tv;
+ }
+ if (d.isMoz) {
+ //We really need to get away from this. Consider a sane isGecko approach for the future.
+ d.isFF = parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1] || dua.split("Shiretoko/")[1]) || undefined;
+ }
+ if (document.all && !d.isOpera) {
+ d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
+ //In cases where the page has an HTTP header or META tag with
+ //X-UA-Compatible, then it is in emulation mode, for a previous
+ //version. Make sure isIE reflects the desired version.
+ //document.documentMode of 5 means quirks mode.
+
+ /** @namespace document.documentMode */
+ if (d.isIE >= 8 && document.documentMode != 5) {
+ d.isIE = document.documentMode;
+ }
+ }
+ };
+
+ /**
+ * fetches a global config entry
+ * @param {String} configName the name of the configuration entry
+ * @param {Object} defaultValue
+ *
+ * @return either the config entry or if none is given the default value
+ */
+ this.getGlobalConfig = function(configName, defaultValue) {
+ /*use(myfaces._impl._util)*/
+
+ if (_this.exists(myfaces, "config") && _this.exists(myfaces.config, configName)) {
+ return myfaces.config[configName];
+ }
+ return defaultValue;
+ };
+
+ /**
+ * check if an element exists in the root
+ */
+ this.exists = function(root, name) {
+ if (!root) {
return false;
- } // Boolean
- root = root[p[i]];
- }
- return true; // Boolean
- };
+ }
- /**
- * Convenience method
- * to fetch the implementation from
- * our lazily binding configuration system
- */
- myfaces._impl.core._Runtime.getImpl = function() {
- myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- };
+ //initial condition root set element not set or null
+ //equals to element exists
+ if (!name) {
+ return true;
+ }
+ //crossported from the dojo toolkit
+ // summary: determine if an object supports a given method
+ // description: useful for longer api chains where you have to test each object in the chain
+ var p = name.split(".");
+ var len = p.length;
+ for (var i = 0; i < len; i++) {
+ //the original dojo code here was false because
+ //they were testing against ! which bombs out on exists
+ //which has a value set to false
+ // (TODO send in a bugreport to the Dojo people)
+
+ if ('undefined' == typeof root[p[i]]) {
+ return false;
+ } // Boolean
+ root = root[p[i]];
+ }
+ return true; // Boolean
+ };
- /**
- * gets the local or global options with local ones having higher priority
- * if no local or global one was found then the default value is given back
- *
- * @param {String} configName the name of the configuration entry
- * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
- *
- * @param {Object} defaultValue
- *
- * @return either the config entry or if none is given the default value
- */
- myfaces._impl.core._Runtime.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
- /*use(myfaces._impl._util)*/
- var _RT = myfaces._impl.core._Runtime;
-
- var globalOption = _RT.getGlobalConfig(configName, defaultValue);
- if (!_RT.exists(localOptions, "myfaces") || !_RT.exists(localOptions.myfaces, configName)) {
- return globalOption;
- }
- return localOptions.myfaces[configName];
- };
+ /**
+ * gets the local or global options with local ones having higher priority
+ * if no local or global one was found then the default value is given back
+ *
+ * @param {String} configName the name of the configuration entry
+ * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
+ *
+ * @param {Object} defaultValue
+ *
+ * @return either the config entry or if none is given the default value
+ */
+ this.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
+ /*use(myfaces._impl._util)*/
- /**
- * encapsulated xhr object which tracks down various implementations
- * of the xhr object in a browser independent 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.core._Runtime.getXHRObject = function() {
- if ('undefined' != typeof XMLHttpRequest && null != XMLHttpRequest) {
- return new XMLHttpRequest();
- }
- //IE
- try {
- return new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
+ return (!_this.exists(localOptions, "myfaces." + configName)) ? _this.getGlobalConfig(configName, defaultValue) : localOptions.myfaces[configName];
+ };
- }
- return new ActiveXObject('Microsoft.XMLHTTP');
- };
+ /**
+ * encapsulated xhr object which tracks down various implementations
+ * of the xhr object in a browser independent 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)
+ */
+ this.getXHRObject = function() {
+ //since this is a global object ie hates it if we do not check for undefined
+ if (window.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.core._Runtime.loadScript = function(src, type, defer, charSet) {
- var xhr = myfaces._impl.core._Runtime.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.core._Runtime.globalEval(xhr.responseText);
+ /**
+ * [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)
+ */
+ this._loadScriptEval = function(src, type, defer, charSet) {
+ var xhr = _this.getXHRObject();
+ xhr.open("GET", src, false);
+
+ if (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) {
+ _this.globalEval(xhr.responseText.replace("\n", "\r\n") + "\r\n//@ sourceURL=" + src);
+ } else {
+ setTimeout(function() {
+ _this.globalEval(xhr.responseText + "\r\n//@ sourceURL=" + src);
+ }, 1);
+ }
} else {
- setTimeout(function() {
- myfaces._impl.core._Runtime.globalEval(xhr.responseText);
- }, 1);
+ throw Error(xhr.responseText);
}
} else {
- throw Error(xhr.responseText);
+ throw Error("Loading of script " + src + " failed ");
}
- } else {
- throw Error("Loading of script " + src + " failed ");
- }
- };
+ };
- myfaces._impl.core._Runtime.loadScriptOnHeadElement = function(src, type, defer, charSet) {
- var head = document.getElementsByTagName("head")[0];
- if ('undefined' == typeof head || null == head)
- {
- head = document.createElement("head");
- var html = document.getElementsByTagName("html");
- html.appendChild(head);
- }
- var script = document.createElement("script");
- script.type = "text/javascript";
- script.src = src;
- head.appendChild(script);
- };
+ this._loadScriptByBrowser = function(src, type, defer, charSet) {
+ //if a head is already present then it is safer to simply
+ //use the body, some browsers prevent head alterations
+ //after the first initial rendering
+ var position = document.getElementsByTagName("body").length ? "body" :"head";
+
+ try {
+ var holder = document.getElementsByTagName(position)[0];
+ if ('undefined' == typeof holder || null == holder)
+ {
+ holder = document.createElement(position);
+ var html = document.getElementsByTagName("html");
+ html.appendChild(holder);
+ }
+ var script = document.createElement("script");
+ script.type = "text/javascript";
+ script.src = src;
+ if (defer) {
+ script.defer = defer;
+ }
+ holder.appendChild(script);
+ } catch (e) {
+
+ return false;
+ }
- /**
- * Extends a class and puts a singleton instance at the reserved namespace instead
- * of its original class
- *
- * @param {function|String} newClass either a unnamed function which can be assigned later or a namespace
- * @param {function} extendsClass the function class to be extended
- * @param {Object} prototypeFunctions (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method
- * @param {Object} prototypeFunctions (Map) an optional map of normal namespace functions which are attached directly to the function of newClass instead of its prototype object
- */
- myfaces._impl.core._Runtime.singletonExtendClass = function(newClass, extendsClass, prototypeFunctions, namespaceFunctions) {
-
- var _RT = myfaces._impl.core._Runtime;
- if (!_RT.isString(newClass)) {
- throw Error("New class namespace must be of type string for static initialisation");
- }
- //namespace already declared we do not do anything further
- if (_RT.fetchNamespace(newClass)) {
- return null;
- }
-
- var initializer = myfaces._impl.core._Runtime.extendClass(newClass, extendsClass, prototypeFunctions, namespaceFunctions);
- if (initializer != null) {
- _RT.applyToGlobalNamespace(newClass, new initializer());
- }
- };
+ return true;
+ };
- /**
- * prototype based delegation inheritance
- *
- * implements prototype delegaton inheritance dest <- a
- *
- * usage var newClass = myfaces._impl.core._Runtime.extends(
- * function (var1, var2) {
- * this.callSuper("constructor", var1,var2);
- * };
- * ,origClass);
- * newClass.prototype.myMethod = function(arg1) {
- * this.callSuper("myMethod", arg1,"hello world");
-
- other option
- myfaces._impl._core._Runtime.extends("myNamespace.newClass", parent, {
- init: function() {constructor...},
- method1: function(f1, f2) {},
- method2: function(f1, f2,f3)
-
- });
- *
- * @param {function|String} newClass either a unnamed function which can be assigned later or a namespace
- * @param {function} extendsClass the function class to be extended
- * @param {Object} prototypeFunctions (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method
- * @param {Object} prototypeFunctions (Map) an optional map of normal namespace functions which are attached directly to the function of newClass instead of its prototype object
- *
- * To explain further
- * prototype functions:
- * newClass.prototype.<prototypeFunction>
- * namspace function
- * newClass.<namespaceFunction> = function() {...}
- */
-
- myfaces._impl.core._Runtime.extendClass = function(newClass, extendsClass, prototypeFunctions) {
- var _RT = myfaces._impl.core._Runtime;
-
- if ('function' != typeof newClass) {
-
- var constructor = null;
- if ('undefined' != typeof prototypeFunctions && null != prototypeFunctions) {
- constructor = ('undefined' != typeof null != prototypeFunctions['constructor_'] && null != prototypeFunctions['constructor_']) ? prototypeFunctions['constructor_'] : function() {
- };
- } else {
- constructor = function() {
- };
+ this.loadScript = function(src, type, defer, charSet) {
+ if (!_this._loadScriptByBrowser(src, type, defer, charSet)) {
+ _this._loadScriptEval(src, type, defer, charSet);
+ }
+ };
+
+ /**
+ * Extends a class and puts a singleton instance at the reserved namespace instead
+ * of its original class
+ *
+ * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace
+ * @param {function} extendsCls the function class to be extended
+ * @param {Object} protoFuncs (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method
+ */
+ this.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) {
+
+ if (!_this.isString(newCls)) {
+ throw Error("New class namespace must be of type string for static initialisation");
}
- if (!_RT.reserveNamespace(newClass, constructor)) {
+ //namespace already declared we do not do anything further
+ if (_this.fetchNamespace(newCls)) {
return null;
}
- newClass = _RT.fetchNamespace(newClass);
- }
- if (null != extendsClass) {
- newClass.prototype = new extendsClass;
- newClass.prototype.constructor = newClass;
- newClass.prototype.parent = extendsClass.prototype;
-
- newClass.prototype._callSuper = function(methodName) {
- var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1);
- this.parent[methodName].apply(this, passThrough);
- };
- }
-
- //we now map the function map in
- if ('undefined' != typeof prototypeFunctions && null != prototypeFunctions) {
- for (var key in prototypeFunctions) {
- if (key != "_callSuper") {
- newClass.prototype[key] = prototypeFunctions[key];
- }
- }
- }
- if ('undefined' != typeof namespaceFunctions && null != namespaceFunctions) {
- for (var key in namespaceFunctions) {
- newClass[key] = namespaceFunctions[key];
+ var clazz = _this.extendClass(newCls, extendsCls, protoFuncs, nmsFuncs);
+ if (clazz != null) {
+ _this.applyToGlobalNamespace(newCls, new clazz());
+ }
+ };
+
+ /**
+ * prototype based delegation inheritance
+ *
+ * implements prototype delegaton inheritance dest <- a
+ *
+ * usage var newClass = this.extends(
+ * function (var1, var2) {
+ * this.callSuper("constructor", var1,var2);
+ * };
+ * ,origClass);
+ * newClass.prototype.myMethod = function(arg1) {
+ * this.callSuper("myMethod", arg1,"hello world");
+
+ other option
+ myfaces._impl._core._Runtime.extends("myNamespace.newClass", parent, {
+ init: function() {constructor...},
+ method1: function(f1, f2) {},
+ method2: function(f1, f2,f3)
+
+ });
+ *
+ * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace
+ * @param {function} extendCls the function class to be extended
+ * @param {Object} protoFuncs (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method
+ *
+ * To explain further
+ * prototype functions:
+ * newClass.prototype.<prototypeFunction>
+ * namspace function
+ * newClass.<namespaceFunction> = function() {...}
+ */
+
+ this.extendClass = function(newCls, extendCls, protoFuncs, nmsFuncs) {
+ if (!this.isString(newCls)) {
+ throw Error("new class namespace must be of type String");
+ }
+
+ if ('function' != typeof newCls) {
+
+ var constr = null;
+ if ('undefined' != typeof protoFuncs && null != protoFuncs) {
+ constr = ('undefined' != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() {
+ };
+ } else {
+ constr = function() {
+ };
+ }
+ if (!_this.reserveNamespace(newCls, constr)) {
+ return null;
+ }
+ newCls = _this.fetchNamespace(newCls);
}
- }
- return newClass;
- };
- /**
- * determines if the embedded scripts have to be evaled manually
- * @return true if a browser combination is given which has to
- * do a manual eval
- * which is currently ie > 5.5, chrome, khtml, webkit safari
- *
- */
- myfaces._impl.core._Runtime.isManualScriptEval = function() {
- var _RT = myfaces._impl.core._Runtime;
- var browser = myfaces._impl.core._Runtime.browser;
- //TODO test this with various browsers so that we have auto eval wherever possible
- //
- //tested currently safari, ie, firefox, opera
- return (_RT.exists(browser, "isIE") &&
- ( browser.isIE > 5.5)) ||
- (_RT.exists(browser, "isKhtml") &&
- (browser.isKhtml > 0)) ||
- (_RT.exists(browser, "isWebKit") &&
- (browser.isWebKit > 0)) ||
- (_RT.exists(browser, "isSafari") &&
- (browser.isSafari > 0));
-
- //another way to determine this without direct user agent parsing probably could
- //be to add an embedded script tag programmatically and check for the script variable
- //set by the script if existing, the add went through an eval if not then we
- //have to deal with it ourselves, this might be dangerous in case of the ie however
- //so in case of ie we have to parse for all other browsers we can make a dynamic
- //check if the browser does auto eval
+ if (extendCls) {
+ newCls.prototype = new extendCls;
+ newCls.prototype.constructor = newCls;
+ newCls.prototype.parent = extendCls.prototype;
+
+ newCls.prototype._callSuper = function(methodName) {
+ var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1);
+ this.parent[methodName].apply(this, passThrough);
+ };
+ }
+
+ var key;
+ //we now map the function map in
+ if (protoFuncs) {
+ for (key in protoFuncs) {
+ if (key != "_callSuper") {
+ newCls.prototype[key] = protoFuncs[key];
+ }
+ }
+ }
+ if (nmsFuncs) {
+ for (key in nmsFuncs) {
+ newCls[key] = nmsFuncs[key];
+ }
+ }
+ return newCls;
+ };
+ /**
+ * determines if the embedded scripts have to be evaled manually
+ * @return true if a browser combination is given which has to
+ * do a manual eval
+ * which is currently ie > 5.5, chrome, khtml, webkit safari
+ *
+ */
+ this.isManualScriptEval = function() {
+
+ var d = _this.browser;
+
+ return (_this.exists(d, "isIE") &&
+ ( d.isIE > 5.5)) ||
+ (_this.exists(d, "isKhtml") &&
+ (d.isKhtml > 0)) ||
+ (_this.exists(d, "isWebKit") &&
+ (d.isWebKit > 0)) ||
+ (_this.exists(d, "isSafari") &&
+ (d.isSafari > 0));
+
+ //another way to determine this without direct user agent parsing probably could
+ //be to add an embedded script tag programmatically and check for the script variable
+ //set by the script if existing, the add went through an eval if not then we
+ //have to deal with it ourselves, this might be dangerous in case of the ie however
+ //so in case of ie we have to parse for all other browsers we can make a dynamic
+ //check if the browser does auto eval
+
+ };
+
+ _this.browserDetection();
};
- myfaces._impl.core._Runtime.browserDetection();
-}
\ No newline at end of file
+}
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Fri May 21 10:51:20 2010
@@ -12,15 +12,15 @@
* limitations under the License.
* under the License.
*/
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Lang.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Queue.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_ListenerQueue.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_Dom.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.util:_HtmlStripper.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxUtils.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQueue.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.impl.core:Impl.js']}", null, null, "UTF-8");
-myfaces._impl.core._Runtime.loadScriptOnHeadElement("#{resource['org.apache.myfaces.core.api:jsf.js']}", null, null, "UTF-8");
\ No newline at end of file
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Lang.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Queue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_ListenerQueue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_Dom.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_HtmlStripper.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxUtils.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQueue.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.core:Impl.js']}", null, null, "UTF-8");
+myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.api:jsf.js']}", null, null, "UTF-8");
\ No newline at end of file
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Fri May 21 10:51:20 2010
@@ -28,6 +28,7 @@
* Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
* Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
*/
+/** @namespace myfaces._impl.xhrCore._AjaxRequest */
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", Object, {
/*all instance vars can be set from the outside
@@ -86,7 +87,7 @@ myfaces._impl.core._Runtime.extendClass(
/*namespace remapping for readability*/
var _Lang = myfaces._impl._util._Lang;
//we fetch in the standard arguments
- _Lang.applyArguments(this, arguments);
+ _Lang.applyArgs(this, arguments);
//if our response handler is not set
if (!this._response) {
@@ -126,9 +127,9 @@ myfaces._impl.core._Runtime.extendClass(
this._xhr.setRequestHeader(this._CONTENT_TYPE, this._contentType);
this._xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
- this._xhr.onreadystatechange = _Lang.hitch(this, this.requestCallback);
+ this._xhr.onreadystatechange = _Lang.hitch(this, this.callback);
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- _Impl.sendEvent(this._xhr, this._context, myfaces._impl.core.Impl._AJAX_STAGE_BEGIN);
+ _Impl.sendEvent(this._xhr, this._context, myfaces._impl.core.Impl.BEGIN);
this._xhr.send(this._requestParameters);
if (this._timeout && this._onTimeout) {
var timeoutId = window.setTimeout(this._onTimeout, this._timeout);
@@ -154,7 +155,7 @@ myfaces._impl.core._Runtime.extendClass(
* Callback method to process the Ajax response
* triggered by RequestQueue
*/
- requestCallback : function() {
+ callback : function() {
var READY_STATE_DONE = 4;
try {
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
@@ -168,7 +169,7 @@ myfaces._impl.core._Runtime.extendClass(
}
}
} catch (e) {
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "requestCallback", e);
+ this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "callback", e);
}
},
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js Fri May 21 10:51:20 2010
@@ -17,6 +17,7 @@
* Version: $Revision: 1.3 $ $Date: 2009/05/31 09:16:44 $
*
*/
+/** @namespace myfaces._impl.xhrCore._AjaxRequestQueue */
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequestQueue", myfaces._impl._util._Queue, {
/**
@@ -28,7 +29,7 @@ myfaces._impl.core._Runtime.extendClass(
/**
* the standard constructur of our class
*/
- constructor_: function(){
+ constructor_: function() {
this._callSuper("constructor");
},
@@ -36,17 +37,25 @@ myfaces._impl.core._Runtime.extendClass(
* delay request, then call enqueue
* @param {Object} request (myfaces._impl.xhrCore._AjaxRequest) request to send
*/
- queueRequest : function(request) {
+ enqueue : function(request) {
if (typeof request._delay == "number") {
this.clearDelayTimeout();
var _Lang = myfaces._impl._util._Lang;
- this.delayTimeoutId = window.setTimeout(
+ this._delayTimeoutId = window.setTimeout(
_Lang.hitch(this, function() {
this.clearDelayTimeout();
this.enqueue(request);
}), request._delay);
} else {
- this.enqueue(request);
+ if (this._curReq == null) {
+ this._curReq = request;
+ this._curReq.send();
+ } else {
+ this._callSuper("enqueue", request);
+ if (request._size != this._size) {
+ this.setQueueSize(request._size);
+ }
+ }
}
},
@@ -56,38 +65,22 @@ myfaces._impl.core._Runtime.extendClass(
*/
clearDelayTimeout : function() {
try {
- if (typeof this.delayTimeoutId == "number") {
- window.clearTimeout(this.delayTimeoutId);
- delete this.delayTimeoutId;
+ if (typeof this._delayTimeoutId == "number") {
+ window.clearTimeout(this._delayTimeoutId);
+ delete this._delayTimeoutId;
}
} catch (e) {
// already timed out
}
},
- /**
- * send a request or keep it in a queue
- * @param {myfaces._impl.xhrCore._AjaxRequest} request - request to send
- */
- enqueue : function(request) {
- if (this._curReq == null) {
- this._curReq = request;
- this._curReq.send();
- } else {
-
- this._callSuper("enqueue",request);
- if (request._queueSize != this._queueSize) {
- this.setQueueSize(request._queueSize);
- }
- }
- },
/**
* process queue, send request, if exists
*/
processQueue: function() {
this._curReq = this.dequeue();
- if (null != this._curReq) {
+ if (this._curReq) {
this._curReq.send();
}
},
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Fri May 21 10:51:20 2010
@@ -18,39 +18,39 @@
*
*/
+/** @namespace myfaces._impl.xhrCore._AjaxResponse */
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxResponse", Object, {
/*partial response types*/
- _RESPONSE_PARTIAL : "partial-response",
- _RESPONSETYPE_ERROR : "error",
- /*TODO: -=Leonardo Uribe=- Does this response type really exists? really from server comes a partial-response with redirect command*/
- /*This really exists, it is for cases where a button issues a command and the server wants to redirect after processing the ajax request*/
- _RESPONSETYPE_REDIRECT : "redirect",
- _RESPONSETYPE_CHANGES : "changes",
+ RESP_PARTIAL : "partial-response",
+ RESP_TYPE_ERROR : "error",
+ RESP_TYPE_REDIRECT : "redirect",
+ RESP_TYPE_CHANGES : "changes",
/*partial commands*/
- _PCMD_CHANGES : "changes",
- _PCMD_UPDATE : "update",
- _PCMD_DELETE : "delete",
- _PCMD_INSERT : "insert",
- _PCMD_EVAL : "eval",
- _PCMD_ERROR : "error",
- _PCMD_ATTRIBUTES : "attributes",
- _PCMD_EXTENSION : "extension",
- _PCMD_REDIRECT : "redirect",
+ CMD_CHANGES : "changes",
+ CMD_UPDATE : "update",
+ CMD_DELETE : "delete",
+ CMD_INSERT : "insert",
+ CMD_EVAL : "eval",
+ CMD_ERROR : "error",
+ CMD_ATTRIBUTES : "attributes",
+ CMD_EXTENSION : "extension",
+ CMD_REDIRECT : "redirect",
/*other constants*/
- _PROP_VIEWSTATE: "javax.faces.ViewState",
- _PROP_VIEWROOT: "javax.faces.ViewRoot",
- _PROP_VIEWHEAD: "javax.faces.ViewHead",
- _PROP_VIEWBODY: "javax.faces.ViewBody",
+ P_VIEWSTATE: "javax.faces.ViewState",
+ P_VIEWROOT: "javax.faces.ViewRoot",
+ P_VIEWHEAD: "javax.faces.ViewHead",
+ P_VIEWBODY: "javax.faces.ViewBody",
/**
* Constructor
- * @param {String} alarmThreshold
+ * @param {function} onException
+ * @param {function} onWarning
*/
constructor_: function(onException, onWarning) {
@@ -64,7 +64,7 @@ myfaces._impl.core._Runtime.extendClass(
* uses response to start Html element replacement
*
* @param {Object} request (xhrRequest) - xhr request object
- * @param {Ojbect} context (Map) - AJAX context
+ * @param {Object} context (Map) - AJAX context
*
* A special handling has to be added to the update cycle
* according to the JSDoc specs if the CDATA block contains html tags the outer rim must be stripped
@@ -83,36 +83,35 @@ myfaces._impl.core._Runtime.extendClass(
// to solve IE error 1072896658 when a Java server sends iso88591
// istead of ISO-8859-1
- if ('undefined' == typeof(request) || null == request) {
+ if (!request) {
throw Exception("jsf.ajaxResponse: The response cannot be null or empty!");
}
if (!_Lang.exists(request, "responseXML")) {
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_EMPTY_RESPONSE);
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.EMPTY_RESPONSE);
return;
}
var xmlContent = request.responseXML;
//ie6+ keeps the parsing response under xmlContent.parserError
//while the rest of the world keeps it as element under the first node
- var parseError
if ((_Lang.exists(xmlContent, "parseError.errorCode") && xmlContent.parseError.errorCode != 0) || _Lang.equalsIgnoreCase(xmlContent.firstChild.tagName, "parsererror")) {
//TODO improve error name and message sending here
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_MALFORMEDXML);
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML);
return;
}
var partials = xmlContent.childNodes[0];
if ('undefined' == typeof partials || partials == null) {
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_MALFORMEDXML);
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML);
return;
} else {
- if (partials.tagName != this._RESPONSE_PARTIAL) {
+ if (partials.tagName != this.RESP_PARTIAL) {
// IE 8 sees XML Header as first sibling ...
partials = partials.nextSibling;
- if ('undefined' == typeof partials || partials == null || partials.tagName != this._RESPONSE_PARTIAL) {
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_MALFORMEDXML);
+ if (!partials || partials.tagName != this.RESP_PARTIAL) {
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML);
return;
}
}
@@ -136,12 +135,12 @@ myfaces._impl.core._Runtime.extendClass(
//which do not use the response writer properly
//we might add this one as custom option in update and
//insert!
- if (tagName == this._PCMD_ERROR) {
+ if (tagName == this.CMD_ERROR) {
this.processError(request, context, childNode);
return;
- } else if (tagName == this._PCMD_REDIRECT) {
+ } else if (tagName == this.CMD_REDIRECT) {
if (!this.processRedirect(request, context, childNode)) return;
- } else if (tagName == this._PCMD_CHANGES) {
+ } else if (tagName == this.CMD_CHANGES) {
if (!this.processChanges(request, context, childNode)) return;
}
}
@@ -169,11 +168,11 @@ myfaces._impl.core._Runtime.extendClass(
//we first have to fetch the real form element because the fragment
//might be detached in some browser implementations
var appliedReplacedFrom = document.getElementById(replacedForms[formCnt].id);
- var viewStateField = myfaces._impl._util._Dom.findFormElement(appliedReplacedFrom, this._PROP_VIEWSTATE);
+ var viewStateField = myfaces._impl._util._Dom.findFormElement(appliedReplacedFrom, this.P_VIEWSTATE);
if (null == viewStateField) {
var element = document.createElement("input");
_Dom.setAttribute(element, "type", "hidden");
- _Dom.setAttribute(element, "name", this._PROP_VIEWSTATE);
+ _Dom.setAttribute(element, "name", this.P_VIEWSTATE);
appliedReplacedFrom.appendChild(element);
_Dom.setAttribute(element, "value", this.appliedViewState);
@@ -189,18 +188,12 @@ myfaces._impl.core._Runtime.extendClass(
* <error-message><![CDATA[message]]></error-message>
* <error>
*/
- var errorName = node.firstChild.textContent;
- var errorMessage = node.childNodes[1].firstChild.data;
+ var errorName = node.firstChild.textContent || "";
+ var errorMessage = node.childNodes[1].firstChild.data || "";
- if ('undefined' == typeof errorName || null == errorName) {
- errorName = "";
- }
- if ('undefined' == typeof errorMessage || null == errorMessage) {
- errorMessage = "";
- }
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_SERVER_ERROR, errorName, errorMessage);
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.SERVER_ERROR, errorName, errorMessage);
},
processRedirect : function(request, context, node) {
@@ -208,10 +201,10 @@ myfaces._impl.core._Runtime.extendClass(
* <redirect url="url to redirect" />
*/
var redirectUrl = node.getAttribute("url");
- if ('undefined' == typeof redirectUrl || null == redirectUrl) {
+ if (!redirectUrl) {
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_MALFORMEDXML, myfaces._impl.core.Impl._ERROR_MALFORMEDXML, "Redirect without url");
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML, myfaces._impl.core.Impl.MALFORMEDXML, "Redirect without url");
return false;
}
redirectUrl = myfaces._impl._util._Lang.trim(redirectUrl);
@@ -242,31 +235,30 @@ myfaces._impl.core._Runtime.extendClass(
//the realignment must happen post change processing
for (var i = 0; i < changes.length; i++) {
- if (changes[i].tagName == "update") {
- if (!this.processUpdate(request, context, changes[i])) return false;
- } else if (changes[i].tagName == this._PCMD_EVAL) {
- //eval is always in CDATA blocks
- _Lang.globalEval(changes[i].firstChild.data);
- } else if (changes[i].tagName == this._PCMD_INSERT) {
- if (!this.processInsert(request, context, changes[i])) return false;
- } else if (changes[i].tagName == this._PCMD_DELETE) {
- if (!this.processDelete(request, context, changes[i])) return false;
- } else if (changes[i].tagName == this._PCMD_ATTRIBUTES) {
- if (!this.processAttributes(request, context, changes[i])) return false;
- } else if (changes[i].tagName == this._PCMD_EXTENSION) {
- //DO nothing we do not have any implementation specifics for now!
- //but if you need some implementation specific stuff
- //you have to insert it here
- // this._responseHandler.doExtension(childNode);
- } else {
- var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
-
- _Impl.sendError(request, context, myfaces._impl.core.Impl._ERROR_MALFORMEDXML);
- return false;
+ switch (changes[i].tagName) {
+ case this.CMD_UPDATE:
+ if (!this.processUpdate(request, context, changes[i])) return false;
+ break;
+ case this.CMD_EVAL:
+ _Lang.globalEval(changes[i].firstChild.data);
+ break;
+ case this.CMD_INSERT:
+ if (!this.processInsert(request, context, changes[i])) return false;
+ break;
+ case this.CMD_DELETE:
+ if (!this.processDelete(request, context, changes[i])) return false;
+ break;
+ case this.CMD_ATTRIBUTES:
+ if (!this.processAttributes(request, context, changes[i])) return false;
+ break;
+ case this.CMD_EXTENSION:
+ break;
+ default:
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+ _Impl.sendError(request, context, myfaces._impl.core.Impl.MALFORMEDXML);
+ return false;
}
}
- //second step we step over all updates which have identifiers to check whether there are lost
- // viewStates
return true;
},
@@ -274,9 +266,9 @@ myfaces._impl.core._Runtime.extendClass(
processUpdate : function(request, context, node) {
/*local namespace remapping*/
var _Dom = myfaces._impl._util._Dom;
- var _Lang = myfaces._impl._util._Lang;
- if (node.getAttribute('id') == this._PROP_VIEWSTATE) {
+
+ if (node.getAttribute('id') == this.P_VIEWSTATE) {
//update the submitting forms viewstate to the new value
// The source form has to be pulled out of the CURRENT document first because the context object
// may refer to an invalid document if an update of the entire body has occurred before this point.
@@ -289,7 +281,7 @@ myfaces._impl.core._Runtime.extendClass(
/*we check for an element and include a namesearch, but only within the bounds of the committing form*/
var element = null;
try {
- element = _Dom.getElementFromForm(this._PROP_VIEWSTATE, sourceForm, true, true);
+ element = _Dom.getElementFromForm(this.P_VIEWSTATE, sourceForm, true, true);
} catch (e) {
//in case of an error here we try an early recovery but throw an error to our error handler
this._onException(request, context, "_AjaxResponse", "processUpdate('javax.faces.ViewState')", e);
@@ -298,10 +290,10 @@ myfaces._impl.core._Runtime.extendClass(
if (null == element) {//no element found we have to append a hidden field
element = document.createElement("input");
_Dom.setAttribute(element, "type", "hidden");
- _Dom.setAttribute(element, "name", this._PROP_VIEWSTATE);
+ _Dom.setAttribute(element, "name", this.P_VIEWSTATE);
sourceForm.appendChild(element);
}
- //viewstate cannot have split cdata blocks so we can skip the costlier operation
+ //viewState cannot have split cdata blocks so we can skip the costlier operation
_Dom.setAttribute(element, "value", viewStateValue);
}
@@ -314,20 +306,20 @@ myfaces._impl.core._Runtime.extendClass(
else
{
// response may contain several blocks
- var cDataBlock = myfaces._impl._util._Dom.concatCDATABlocks(node);
+ var cDataBlock = _Dom.concatCDATABlocks(node);
switch (node.getAttribute('id')) {
- case this._PROP_VIEWROOT:
+ case this.P_VIEWROOT:
this._replaceBody(request, context, cDataBlock);
break;
- case this._PROP_VIEWHEAD:
+ case this.P_VIEWHEAD:
//we cannot replace the head, almost no browser allows this, some of them throw errors
//others simply ignore it or replace it and destroy the dom that way!
throw new Error("Head cannot be replaced, due to browser deficiencies!");
break;
- case this._PROP_VIEWBODY:
+ case this.P_VIEWBODY:
//we assume the cdata block is our body including the tag
this._replaceBody(request, context, cDataBlock);
break;
@@ -392,7 +384,7 @@ myfaces._impl.core._Runtime.extendClass(
*/
_replaceElement : function(request, context, oldElement, newData) {
return this.replaceHtmlItem(request, context,
- oldElement, newData, this.m_htmlFormElement);
+ oldElement, newData);
}
,
@@ -412,8 +404,8 @@ myfaces._impl.core._Runtime.extendClass(
// (itemIdToReplace instanceof Node) is NOT compatible with IE8
var item = (!_Lang.isString(itemIdToReplace)) ? itemIdToReplace :
myfaces._impl._util._Dom.getElementFromForm(itemIdToReplace, form);
- if ('undefined' == typeof item || null == item) {
- throw Error("myfaces._impl.xhrCore._AjaxResponse.replaceHtmlItem: item with identifier "+itemIdToReplace.toString()+" could not be found");
+ if (!item) {
+ throw Error("myfaces._impl.xhrCore._AjaxResponse.replaceHtmlItem: item with identifier " + itemIdToReplace.toString() + " could not be found");
}
return myfaces._impl._util._Dom.outerHTML(item, markup);
@@ -444,16 +436,16 @@ myfaces._impl.core._Runtime.extendClass(
var beforeId = node.getAttribute('before');
var afterId = node.getAttribute('after');
- var insertSet = 'undefined' != typeof insertId && null != insertId && _Lang.trim(insertId) != "";
- var beforeSet = 'undefined' != typeof beforeId && null != beforeId && _Lang.trim(beforeId) != "";
- var afterSet = 'undefined' != typeof afterId && null != afterId && _Lang.trim(afterId) != "";
+ var isInsert = insertId && _Lang.trim(insertId) != "";
+ var isBefore = beforeId && _Lang.trim(beforeId) != "";
+ var isAfter = afterId && _Lang.trim(afterId) != "";
- if (!insertSet) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
+ if (!isInsert) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, id must be present");
return false;
}
- if (!(beforeSet || afterSet)) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
+ if (!(isBefore || isAfter)) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
return false;
}
//either before or after but not two at the same time
@@ -462,11 +454,11 @@ myfaces._impl.core._Runtime.extendClass(
var cDataBlock = _Dom.concatCDATABlocks(node);
var replacementFragment;
- if (beforeSet) {
+ if (isBefore) {
beforeId = _Lang.trim(beforeId);
var beforeNode = document.getElementById(beforeId);
- if ('undefined' == typeof beforeNode || null == beforeNode) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, before node of id " + beforeId + " does not exist in document");
+ if (!beforeNode) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, before node of id " + beforeId + " does not exist in document");
return false;
}
/**
@@ -482,15 +474,15 @@ myfaces._impl.core._Runtime.extendClass(
replacementFragment = this.replaceHtmlItem(request, context,
nodeHolder, cDataBlock, null);
- if ('undefined' != typeof replacementFragment && null != replacementFragment) {
+ if (replacementFragment) {
this.changeTrace.push(replacementFragment);
}
} else {
afterId = _Lang.trim(afterId);
var afterNode = document.getElementById(afterId);
- if ('undefined' == typeof afterNode || null == afterNode) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, after node of id " + after + " does not exist in document");
+ if (!afterNode) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML, _Impl.MALFORMEDXML, "Error in PPR Insert, after node of id " + afterId + " does not exist in document");
return false;
}
@@ -501,7 +493,7 @@ myfaces._impl.core._Runtime.extendClass(
replacementFragment = this.replaceHtmlItem(request, context,
nodeHolder, cDataBlock, null);
- if ('undefined' != typeof replacementFragment && null != replacementFragment) {
+ if (replacementFragment) {
this.changeTrace.push(replacementFragment);
}
@@ -515,9 +507,9 @@ myfaces._impl.core._Runtime.extendClass(
var _Dom = myfaces._impl._util._Dom;
var deleteId = node.getAttribute('id');
- if ('undefined' == typeof deleteId || null == deleteId) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML,
- _Impl._ERROR_MALFORMEDXML, "Error in delete, id not in xml markup");
+ if (!deleteId) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML,
+ _Impl.MALFORMEDXML, "Error in delete, id not in xml markup");
return false;
}
@@ -538,49 +530,50 @@ myfaces._impl.core._Runtime.extendClass(
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
//<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
- var elementId = node.getAttribute('id');
- if ('undefined' == typeof elementId || null == elementId) {
- _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML
- , _Impl._ERROR_MALFORMEDXML, "Error in attributes, id not in xml markup");
+ var elemId = node.getAttribute('id');
+ if (!elemId) {
+ _Impl.sendError(request, context, _Impl.MALFORMEDXML
+ , _Impl.MALFORMEDXML, "Error in attributes, id not in xml markup");
return false;
}
var childNodes = node.childNodes;
- if ('undefined' == typeof childNodes || null == childNodes) {
+ if (!childNodes) {
return false;
}
for (var loop2 = 0; loop2 < childNodes.length; loop2++) {
var attributesNode = childNodes[loop2];
- var attributeName = attributesNode.getAttribute("name");
- var attributeValue = attributesNode.getAttribute("value");
+ var attrName = attributesNode.getAttribute("name");
+ var attrValue = attributesNode.getAttribute("value");
- if ('undefined' == typeof attributeName || null == attributeName) {
+ if (!attrName) {
continue;
}
- attributeName = myfaces._impl._util._Lang.trim(attributeName);
+ attrName = myfaces._impl._util._Lang.trim(attrName);
/*no value means reset*/
- if ('undefined' == typeof attributeValue || null == attributeValue) {
- attributeValue = "";
+ //value can be of boolean value hence full check
+ if ('undefined' == typeof attrValue || null == attrValue) {
+ attrValue = "";
}
- switch (elementId) {
- case this._PROP_VIEWROOT:
+ switch (elemId) {
+ case this.P_VIEWROOT:
throw new Error("Changing of viewRoot attributes is not supported");
break;
- case this._PROP_VIEWHEAD:
+ case this.P_VIEWHEAD:
throw new Error("Changing of head attributes is not supported");
break;
- case this._PROP_VIEWBODY:
+ case this.P_VIEWBODY:
var element = document.getElementsByTagName("body")[0];
- _Dom.setAttribute(element, attributeName, attributeValue);
+ _Dom.setAttribute(element, attrName, attrValue);
break;
default:
- _Dom.setAttribute(document.getElementById(elementId), attributeName, attributeValue);
+ _Dom.setAttribute(document.getElementById(elemId), attrName, attrValue);
break;
}
@@ -588,5 +581,4 @@ myfaces._impl.core._Runtime.extendClass(
return true;
}
-})
- ;
+});
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=946969&r1=946968&r2=946969&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Fri May 21 10:51:20 2010
@@ -17,11 +17,12 @@
* Version: $Revision: 1.1 $ $Date: 2009/05/26 21:24:42 $
*
*/
-
+/** @namespace myfaces._impl.xhrCore._AjaxUtils */
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxUtils", Object, {
/**
* Constructor
- * @param {String} alarmThreshold - Error Level
+ * @param {function} onException - exception handler
+ * @param {function} onWarning - warning handler
*/
constructor_ : function(onException, onWarning) {
@@ -40,14 +41,14 @@ myfaces._impl.core._Runtime.extendClass(
encodeSubmittableFields : function(request, context, item,
parentItem, partialIds) {
try {
- if (parentItem == null) {
+ if (!parentItem) {
this._onWarning(request, context,"myfaces._impl.xhrCore._AjaxUtils" ,"encodeSubmittableFields "+"Html-Component is not nested in a Form-Tag");
return null;
}
var strBuf = [];
- if (partialIds != null && partialIds.length > 0) {
+ if (partialIds && partialIds.length > 0) {
// recursivly check items
this.encodePartialSubmit(parentItem, false, partialIds, strBuf);
} else {
@@ -59,7 +60,7 @@ myfaces._impl.core._Runtime.extendClass(
}
// if triggered by a Button send it along
- if ('undefined' != typeof item && null != item && item.type != null && item.type.toLowerCase() == "submit") {
+ if (item && item.type && item.type.toLowerCase() == "submit") {
strBuf.push(encodeURIComponent(item.name));
strBuf.push("=");
strBuf.push(encodeURIComponent(item.value));
@@ -97,14 +98,14 @@ myfaces._impl.core._Runtime.extendClass(
var id = curNode.id;
var name = curNode.name;
- var ppsElement = id && _Lang.arrayContains(partialIds, id);
- return ppsElement || (name != null && name == _Impl._PROP_VIEWSTATE);
+ var ppsElement = id && _Lang.contains(partialIds, id);
+ return ppsElement || (name != null && name == _Impl.P_VIEWSTATE);
};
var nodes = _Dom.findAll(node, nodeFilter, true);
if (nodes) {
- for (cnt = 0; cnt < nodes.length; cnt++) {
+ for (var cnt = 0; cnt < nodes.length; cnt++) {
this.encodeElement(nodes[cnt], strBuf);
}
}
@@ -153,11 +154,11 @@ myfaces._impl.core._Runtime.extendClass(
* @param {} strBuf -
*/
encodeElement : function(element, strBuf) {
- var elementName = (null != element.name || 'undefined' != typeof element.name) ? element.name : element.id;
- var elementTagName = element.tagName.toLowerCase();
- var elementType = element.type;
- if (elementType != null) {
- elementType = elementType.toLowerCase();
+ var name = (null != element.name || 'undefined' != typeof element.name) ? element.name : element.id;
+ var tagName = element.tagName.toLowerCase();
+ var elemType = element.type;
+ if (elemType != null) {
+ elemType = elemType.toLowerCase();
}
// routine for all elements
@@ -165,8 +166,8 @@ myfaces._impl.core._Runtime.extendClass(
// - process only inputs, textareas and selects
// - elements muest have attribute "name"
// - elements must not be disabled
- if (((elementTagName == "input" || elementTagName == "textarea" || elementTagName == "select") &&
- (elementName != null && elementName != "")) && !element.disabled) {
+ if (((tagName == "input" || tagName == "textarea" || tagName == "select") &&
+ (name != null && name != "")) && !element.disabled) {
// routine for select elements
// rules:
@@ -176,7 +177,7 @@ myfaces._impl.core._Runtime.extendClass(
// "name=DisplayValue"
// - if select multi and multple selected => "name=value1&name=value2"
// - if select and selectedIndex=-1 don't submit
- if (elementTagName == "select") {
+ if (tagName == "select") {
// selectedIndex must be >= 0 sein to be submittet
if (element.selectedIndex >= 0) {
var uLen = element.options.length;
@@ -184,7 +185,7 @@ myfaces._impl.core._Runtime.extendClass(
// find all selected options
if (element.options[u].selected) {
var elementOption = element.options[u];
- strBuf.push(encodeURIComponent(elementName));
+ strBuf.push(encodeURIComponent(name));
strBuf.push("=");
if (elementOption.getAttribute("value") != null) {
strBuf.push(encodeURIComponent(elementOption.value));
@@ -201,10 +202,10 @@ myfaces._impl.core._Runtime.extendClass(
// rules:
// - don't submit no selects (processed above), buttons, reset buttons, submit buttons,
// - submit checkboxes and radio inputs only if checked
- if ((elementTagName != "select" && elementType != "button"
- && elementType != "reset" && elementType != "submit" && elementType != "image")
- && ((elementType != "checkbox" && elementType != "radio") || element.checked)) {
- strBuf.push(encodeURIComponent(elementName));
+ if ((tagName != "select" && elemType != "button"
+ && elemType != "reset" && elemType != "submit" && elemType != "image")
+ && ((elemType != "checkbox" && elemType != "radio") || element.checked)) {
+ strBuf.push(encodeURIComponent(name));
strBuf.push("=");
strBuf.push(encodeURIComponent(element.value));
strBuf.push("&");