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 2009/04/23 13:04:51 UTC
svn commit: r767890 [1/2] - in
/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces:
_impl/_util/ _impl/core/ _impl/xhrCore/ api/
Author: werpu
Date: Thu Apr 23 11:04:51 2009
New Revision: 767890
URL: http://svn.apache.org/viewvc?rev=767890&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2211
https://issues.apache.org/jira/browse/MYFACES-2213
Modified:
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Logger.js
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/core/jsf_impl.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/_AjaxRequestQueue.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
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_xhrCoreAdapter.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js?rev=767890&r1=767889&r2=767890&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangUtils.js Thu Apr 23 11:04:51 2009
@@ -86,16 +86,16 @@
* backported from dojo
* Converts an array-like object (i.e. arguments, DOMCollection) to an
array. Returns a new Array with the elements of obj.
- * @param obj the object to "arrayify". We expect the object to have, at a
+ * @param {Object} obj the object to "arrayify". We expect the object to have, at a
minimum, a length property which corresponds to integer-indexed
properties.
- * @param offset the location in obj to start iterating from. Defaults to 0.
+ * @param {Number}Êoffset the location in obj to start iterating from. Defaults to 0.
Optional.
- * @param startWith An array to pack with the properties of obj. If provided,
+ * @param {Array} startWith An array to pack with the properties of obj. If provided,
properties in obj are appended at the end of startWith and
startWith is the returned array.
*/
- myfaces._impl._util._LangUtils._toArray = function(/*Object*/obj, /*Number?*/offset, /*Array?*/ startWith) {
+ myfaces._impl._util._LangUtils._toArray = function(obj, offset, startWith) {
// summary:
// Converts an array-like object (i.e. arguments, DOMCollection) to an
// array. Returns a new Array with the elements of obj.
@@ -117,11 +117,23 @@
return arr; // Array
};
- myfaces._impl._util._LangUtils.trimStringInternal = function(/*string*/ it,/*regexp*/ splitter) {
+ /**
+ * Helper function to provide a trim with a given splitter regular expression
+ * @param {string} it the string to be trimmed
+ * @param {regexp} splitter the splitter regular expressiion
+ *
+ * FIXME is this still used?
+ */
+ myfaces._impl._util._LangUtils.trimStringInternal = function(it, splitter) {
return myfaces._impl._util._LangUtils.strToArray(it, splitter).join(splitter);
};
-
+ /**
+ * String to array function performs a string to array transformation
+ * @param {String} it the string which has to be changed into an array
+ * @param {RegExp} splitter our splitter reglar expression
+ * @return an array of the splitted string
+ */
myfaces._impl._util._LangUtils.strToArray = function(/*string*/ it,/*regexp*/ splitter) {
// summary:
// Return true if it is a String
@@ -139,6 +151,7 @@
/**
* hyperfast trim
* http://blog.stevenlevithan.com/archives/faster-trim-javascript
+ * crossported from dojo
*/
myfaces._impl._util._LangUtils.trim = function(/*string*/ str) {
@@ -149,6 +162,12 @@
return str.slice(0, i + 1);
};
+ /**
+ * Splits a string and fetches the last element of the String
+ * @param {String} theString the string to be splitted
+ * @param {String} delimiter a deliminating string regexp
+ *
+ */
myfaces._impl._util._LangUtils.splitAndGetLast = function(theString, delimiter) {
var arr = theString.split(delimiter);
return arr[arr.length - 1];
@@ -158,6 +177,10 @@
/**
* Backported from dojo
+ * a failsafe string determination method
+ * (since in javascript String != "" typeof alone fails!)
+ * @param it {anything} the object to be checked for being a string
+ * @return true in case of being a string false otherwiseÊ
*/
myfaces._impl._util._LangUtils.isString = function(/*anything*/ it) {
// summary:
@@ -170,6 +193,11 @@
* this is helpful in situations when function reassignments
* can happen
* (notably happens often in lazy xhr code)
+ *
+ * @param {Function} scope of the function to be executed in
+ * @param {Function} method to be executed
+ *
+ * @return whatevery the executed method returns
*/
myfaces._impl._util._LangUtils.hitch = function(/*Object*/scope, /*Function|String*/method /*,...*/) {
// summary:
@@ -213,7 +241,11 @@
return method.apply(scope, arguments || []);
}; // Function
};
- /*used internally to lazy init the logger*/
+ /**
+ * used internally to lazy init the logger
+ * Lazy init for the logging subsystem
+ * @deprecated will be removed soon
+ */
myfaces._impl._util._LangUtils._getLogger = function() {
if(null == myfaces._impl._util._LangUtils._logger) {
myfaces._impl._util._LangUtils._logger = myfaces._impl._util._Logger.getInstance();
@@ -221,6 +253,7 @@
return myfaces._impl._util._LangUtils._logger;
};
+
myfaces._impl._util._LangUtils._hitchArgs = function(scope, method /*,...*/) {
var pre = this._toArray(arguments, 2);
var named = this.isString(method);
@@ -284,8 +317,8 @@
/**
* checks if an array contains an element
- * @param arr array
- * @param string_name string to check for
+ * @param {Array} arr array
+ * @param {String} string_name string to check for
*/
myfaces._impl._util._LangUtils.arrayContains = function(arr, string_name) {
for ( var loop = 0; loop < arr.length; loop++) {
@@ -297,7 +330,14 @@
},
/**
+ * Concatenates an array to a string
+ * @param {Array} arr the array to be concatenated
+ * @param {String} delimiter, the concateation delimiter if none is set \n is used
*
+ * @return the concatenated array, one special behavior to enable j4fry compatibility has been added
+ * if no delimiter is used the [entryNumber]+entry is generated for a single entry
+ * TODO check if this is still needed it is somewhat outside of the scope of the function
+ * and functionalitywise dirty
*/
myfaces._impl._util._LangUtils.arrayToString = function(/*String or array*/ arr, /*string*/ delimiter) {
if( myfaces._impl._util._LangUtils.isString(arr) ) {
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Logger.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Logger.js?rev=767890&r1=767889&r2=767890&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Logger.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Logger.js Thu Apr 23 11:04:51 2009
@@ -20,6 +20,13 @@
_reserveMyfacesNamespaces();
+/**
+ *Logging subsystem
+ *@deprecated will probably dropped in the near future
+ *it is not used anymore due to jsf.js having
+ *some error handling facilities!
+ *
+ */
if(!myfaces._impl._util._LangUtils.exists(myfaces, "_Logger")) {
myfaces._impl._util._Logger = function() {
var targetDiv = document.getElementById("log_console");
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=767890&r1=767889&r2=767890&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 Thu Apr 23 11:04:51 2009
@@ -18,390 +18,390 @@
*
*/
-if(!window.myfaces) window.myfaces = {};
-if(!myfaces.xhrCore) myfaces.xhrCore = {};
+_reserveMyfacesNamespaces();
-/**
- * Constructor
- */
-myfaces._impl._util._Utils = function() {
+if(!myfaces._impl._util._LangUtils.exists(myfaces._impl._util,"_Utils")) {
+ /**
+ * Constructor
+ */
+ myfaces._impl._util._Utils = function() {
}
-/**
- * [STATIC]
- * Run through the given Html item and execute the inline scripts
- * (IE doesn't do this by itself)
- * @param {XMLHTTPRequest} request
- * @param {Map} context
- * @param {HtmlElement} item
- */
-myfaces._impl._util._Utils.runScripts = function(request, context, item) {
- 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;
+ /**
+ * [STATIC]
+ * Run through the given Html item and execute the inline scripts
+ * (IE doesn't do this by itself)
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
+ * @param {HtmlElement} item
+ */
+ myfaces._impl._util._Utils.runScripts = function(request, context, item) {
+ 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;
+ }
}
+ window.execScript(test); // run the script
+ } catch (e) {
+ myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "runScripts", e);
+ }
+ } else {
+ var child = item.firstChild;
+ while (child) {
+ myfaces._impl._util._Utils.runScripts(request, context, child);
+ child = child.nextSibling;
}
- window.execScript(test); // run the script
- } catch (e) {
- myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "runScripts", e);
- }
- } else {
- var child = item.firstChild;
- while (child) {
- myfaces._impl._util._Utils.runScripts(request, context, child);
- child = child.nextSibling;
}
}
}
-}
-/**
- * Simple delete on an existing item
- */
-myfaces._impl._util._Utils.deleteItem = function(request, context, itemIdToReplace) {
- var item = document.getElementById(itemIdToReplace);
- if (item == null) {
- myfaces._impl.xhrCore._Exception.throwNewWarning
- (request, context, "Utils", "deleteItem", "Unknown Html-Component-ID: " + itemIdToReplace);
- return;
- }
-
- item.parentNode.removeChild(item);
-}
-
-/**
- * [STATIC]
- * Replaces HTML elements through others
- * @param {XMLHTTPRequest} request
- * @param {Map} context
- * @param {String|node} itemIdToReplace - ID of the element to replace
- * @param {String} newTag - the new tag
- * @param {HTML Element} form - form element that is parent of the element
- */
-myfaces._impl._util._Utils.replaceHtmlItem = function(request, context, itemIdToReplace, newTag, form) {
- try {
-
-
- var item = (itemIdToReplace instanceof Node) ? itemIdToReplace :
- myfaces._impl._util._Utils.getElementFromForm(request, context, itemIdToReplace, form);
+ /**
+ * Simple delete on an existing item
+ */
+ myfaces._impl._util._Utils.deleteItem = function(request, context, itemIdToReplace) {
+ var item = document.getElementById(itemIdToReplace);
if (item == null) {
myfaces._impl.xhrCore._Exception.throwNewWarning
- (request, context, "Utils", "replaceHTMLItem", "Unknown Html-Component-ID: " + itemIdToReplace);
+ (request, context, "Utils", "deleteItem", "Unknown Html-Component-ID: " + itemIdToReplace);
return;
}
- if (newTag != "") {
- if (typeof window.Range != 'undefined'
- && typeof Range.prototype.createContextualFragment == 'function') {
- var range = document.createRange();
- range.setStartBefore(item);
- var fragment = range.createContextualFragment(newTag);
- item.parentNode.insertBefore(fragment, item);
- } else {
- item.insertAdjacentHTML('beforeBegin', newTag);
- }
- if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
- myfaces._impl._util._Utils.runScripts(request, context, item.previousSibling);
- }
- }
-
- // and remove the old item
item.parentNode.removeChild(item);
- } catch (e) {
- myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "replaceHTMLItem", e);
}
-};
+ /**
+ * [STATIC]
+ * Replaces HTML elements through others
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
+ * @param {String|node} itemIdToReplace - ID of the element to replace
+ * @param {String} newTag - the new tag
+ * @param {HTML Element} form - form element that is parent of the element
+ */
+ myfaces._impl._util._Utils.replaceHtmlItem = function(request, context, itemIdToReplace, newTag, form) {
+ try {
-myfaces._impl._util._Utils.ieQuircksEvents = {
- "onabort": true,
- "onload":true,
- "onunload":true,
- "onchange": true,
- "onsubmit": true,
- "onreset": true,
- "onselect": true,
- "onblur": true,
- "onfocus": true,
- "onkeydown": true,
- "onkeypress": true,
- "onkeyup": true,
- "onclick": true,
- "ondblclick": true,
- "onmousedown": true,
- "onmousemove": true,
- "onmouseout": true,
- "onmouseover": true,
- "onmouseup": true
-};
-/**
- * bugfixing for ie6 which does not cope properly with setAttribute
- */
-myfaces._impl._util._Utils.setAttribute = function(domNode, attribute, value) {
+ var item = (itemIdToReplace instanceof Node) ? itemIdToReplace :
+ myfaces._impl._util._Utils.getElementFromForm(request, context, itemIdToReplace, form);
+ if (item == null) {
+ myfaces._impl.xhrCore._Exception.throwNewWarning
+ (request, context, "Utils", "replaceHTMLItem", "Unknown Html-Component-ID: " + itemIdToReplace);
+ return;
+ }
- if(!myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
- domNode.setAttribute(attribute,value);
- return;
- }
- //Now to the broken browsers IE6+.... ie7 and ie8 quirks mode
+ if (newTag != "") {
+ if (typeof window.Range != 'undefined'
+ && typeof Range.prototype.createContextualFragment == 'function') {
+ var range = document.createRange();
+ range.setStartBefore(item);
+ var fragment = range.createContextualFragment(newTag);
+ item.parentNode.insertBefore(fragment, item);
+ } else {
+ item.insertAdjacentHTML('beforeBegin', newTag);
+ }
+ if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
+ myfaces._impl._util._Utils.runScripts(request, context, item.previousSibling);
+ }
+ }
+
+ // and remove the old item
+ item.parentNode.removeChild(item);
+ } catch (e) {
+ myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "replaceHTMLItem", e);
+ }
+ };
- //now ie has the behavior of not wanting events to be set directly and also
- //class must be renamed to classname
- //according to http://www.quirksmode.org/dom/w3c_core.html it does not set styles
- //also class == className we have to rechange that
- //additionally events are not triggered as well
-
- //what we do is following for now:
- //1. remap the class
- attribute = attribute.toLowerCase();
-
- if(attribute === "class") {
- domNode["className"] = value;
- } else if(attribute === style) {
- //We have to split the styles here and assign them one by one
- var styleEntries = value.split(";");
- for(var loop = 0; loop < styleEntries.length; loop++) {
- var keyVal = styleEntries[loop].split(":");
- domNode["style"][keyVal[0]] = keyVal[1];
- }
- } else {
- //check if the attribute is an event, since this applies only
- //to quirks mode of ie anyway we can live with the standard html4/xhtml
- //ie supported events
- if(myfaces._impl._util._Utils.ieQuircksEvents[attribute]) {
- if(myfaces._impl._util._LangUtils.isString(attribute)) {
- domNode[attribute] = function(event) {
- eval(attribute);
- };
+ myfaces._impl._util._Utils.ieQuircksEvents = {
+ "onabort": true,
+ "onload":true,
+ "onunload":true,
+ "onchange": true,
+ "onsubmit": true,
+ "onreset": true,
+ "onselect": true,
+ "onblur": true,
+ "onfocus": true,
+ "onkeydown": true,
+ "onkeypress": true,
+ "onkeyup": true,
+ "onclick": true,
+ "ondblclick": true,
+ "onmousedown": true,
+ "onmousemove": true,
+ "onmouseout": true,
+ "onmouseover": true,
+ "onmouseup": true
+ };
+
+ /**
+ * bugfixing for ie6 which does not cope properly with setAttribute
+ */
+ myfaces._impl._util._Utils.setAttribute = function(domNode, attribute, value) {
+
+ if(!myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
+ domNode.setAttribute(attribute,value);
+ return;
+ }
+ //Now to the broken browsers IE6+.... ie7 and ie8 quirks mode
+
+
+ //now ie has the behavior of not wanting events to be set directly and also
+ //class must be renamed to classname
+ //according to http://www.quirksmode.org/dom/w3c_core.html it does not set styles
+ //also class == className we have to rechange that
+ //additionally events are not triggered as well
+
+ //what we do is following for now:
+ //1. remap the class
+ attribute = attribute.toLowerCase();
+
+ if(attribute === "class") {
+ domNode["className"] = value;
+ } else if(attribute === style) {
+ //We have to split the styles here and assign them one by one
+ var styleEntries = value.split(";");
+ for(var loop = 0; loop < styleEntries.length; loop++) {
+ var keyVal = styleEntries[loop].split(":");
+ domNode["style"][keyVal[0]] = keyVal[1];
}
+ } else {
+ //check if the attribute is an event, since this applies only
+ //to quirks mode of ie anyway we can live with the standard html4/xhtml
+ //ie supported events
+ if(myfaces._impl._util._Utils.ieQuircksEvents[attribute]) {
+ if(myfaces._impl._util._LangUtils.isString(attribute)) {
+ domNode[attribute] = function(event) {
+ eval(attribute);
+ };
+ }
+ }
+ domNode[attribute] = value;
}
- domNode[attribute] = value;
- }
//TODO this needs further testing I will leave it for now...
-};
+ };
-/**
- * [STATIC]
- * Determines whether the user agent is IE or not
- * @return {boolean} - true if it is IE
- */
-myfaces._impl._util._Utils.isUserAgentInternetExplorer = function() {
- return window.ActiveXObject;
-};
-
-/**
- * [STATIC]
- * gets an element from a form with its id -> sometimes two elements have got
- * the same id but are located in different forms -> MyFaces 1.1.4 two forms ->
- * 2 inputHidden fields with ID jsf_tree_64 & jsf_state_64 ->
- * http://www.arcknowledge.com/gmane.comp.jakarta.myfaces.devel/2005-09/msg01269.html
- * @param {XMLHTTPRequest} request
- * @param {Map} context
- * @param {String} itemId - ID of the HTML element located inside the form
- * @param {Html-Element} form - form element containing the element
- * @return {Html-Element} - return the element if found else null
- */
-myfaces._impl._util._Utils.getElementFromForm = function(request, context, itemId, form) {
- try {
+ /**
+ * [STATIC]
+ * Determines whether the user agent is IE or not
+ * @return {boolean} - true if it is IE
+ */
+ myfaces._impl._util._Utils.isUserAgentInternetExplorer = function() {
+ return window.ActiveXObject;
+ };
+
+ /**
+ * [STATIC]
+ * gets an element from a form with its id -> sometimes two elements have got
+ * the same id but are located in different forms -> MyFaces 1.1.4 two forms ->
+ * 2 inputHidden fields with ID jsf_tree_64 & jsf_state_64 ->
+ * http://www.arcknowledge.com/gmane.comp.jakarta.myfaces.devel/2005-09/msg01269.html
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
+ * @param {String} itemId - ID of the HTML element located inside the form
+ * @param {Html-Element} form - form element containing the element
+ * @return {Html-Element} - return the element if found else null
+ */
+ myfaces._impl._util._Utils.getElementFromForm = function(request, context, itemId, form) {
+ try {
- if('undefined' == typeof form || form == null) {
- return document.getElementById(itemId);
- }
+ if('undefined' == typeof form || form == null) {
+ return document.getElementById(itemId);
+ }
- var fLen = form.elements.length;
- for ( var f = 0; f < fLen; f++) {
- var element = form.elements[f];
- if (element.id != null && element.id == itemId) {
- return element;
+ var fLen = form.elements.length;
+ for ( var f = 0; f < fLen; f++) {
+ var element = form.elements[f];
+ if (element.id != null && element.id == itemId) {
+ return element;
+ }
}
+ // element not found inside the form -> try document.getElementById
+ // (kann be null if element doesn't exist)
+ return document.getElementById(itemId);
+ } catch (e) {
+ myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "getElementFromForm", e);
}
- // element not found inside the form -> try document.getElementById
- // (kann be null if element doesn't exist)
- return document.getElementById(itemId);
- } catch (e) {
- myfaces._impl.xhrCore._Exception.throwNewError(request, context, "Utils", "getElementFromForm", e);
- }
-};
+ };
-/**
- * [STATIC]
- * gets a parent of an item with a given tagname
- * @param {XMLHTTPRequest} request
- * @param {Map} context
- * @param {HtmlElement} item - child element
- * @param {String} parentName - TagName of parent element
- */
-myfaces._impl._util._Utils.getParent = function(request, context, item, parentName) {
- try {
- // parent tag parentName suchen
- var parentItem = item.parentNode;
- while (parentItem != null
- && parentItem.tagName.toLowerCase() != parentName) {
- parentItem = parentItem.parentNode;
- }
- if (parentItem != null) {
- return parentItem;
- } else {
- myfaces._impl.xhrCore._Exception.throwNewWarning
- (request, context, "Utils", "getParent", "The item has no parent with type <" + parentName + ">");
- return null;
+ /**
+ * [STATIC]
+ * gets a parent of an item with a given tagname
+ * @param {XMLHTTPRequest} request
+ * @param {Map} context
+ * @param {HtmlElement} item - child element
+ * @param {String} parentName - TagName of parent element
+ */
+ myfaces._impl._util._Utils.getParent = function(request, context, item, parentName) {
+ try {
+ // parent tag parentName suchen
+ var parentItem = item.parentNode;
+ while (parentItem != null
+ && parentItem.tagName.toLowerCase() != parentName) {
+ parentItem = parentItem.parentNode;
+ }
+ if (parentItem != null) {
+ return parentItem;
+ } else {
+ myfaces._impl.xhrCore._Exception.throwNewWarning
+ (request, context, "Utils", "getParent", "The item has no parent with type <" + parentName + ">");
+ return null;
+ }
+ } catch (e) {
+ myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "getParent", e);
}
- } catch (e) {
- myfaces._impl.xhrCore._Exception.throwNewError (request, context, "Utils", "getParent", e);
- }
-};
+ };
-/**
- * [STATIC]
- * gets the child of an item with a given tagname
- * @param {HtmlElement} item - parent element
- * @param {String} childName - TagName of child element
- * @param {String} itemName - name-Attribut the child can have (can be null)
- */
-myfaces._impl._util._Utils.getChild = function(item, childName, itemName) {
- var childItems = item.childNodes;
- for ( var c = 0, cLen = childItems.length; c < cLen; c++) {
- if (childItems[c].tagName != null
- && childItems[c].tagName.toLowerCase() == childName
- && (itemName == null || (itemName != null && itemName == childItems[c]
- .getAttribute("name")))) {
- return childItems[c];
+ /**
+ * [STATIC]
+ * gets the child of an item with a given tagname
+ * @param {HtmlElement} item - parent element
+ * @param {String} childName - TagName of child element
+ * @param {String} itemName - name-Attribut the child can have (can be null)
+ */
+ myfaces._impl._util._Utils.getChild = function(item, childName, itemName) {
+ var childItems = item.childNodes;
+ for ( var c = 0, cLen = childItems.length; c < cLen; c++) {
+ if (childItems[c].tagName != null
+ && childItems[c].tagName.toLowerCase() == childName
+ && (itemName == null || (itemName != null && itemName == childItems[c]
+ .getAttribute("name")))) {
+ return childItems[c];
+ }
}
+ return null;
}
- return null;
-}
-/**
- * Simplified encapsulation function to strip the html content from a given string
- * @param {String} content, our content to be stripped from its outer html areas
- * return the stripped content or null if no stripping was possible
- */
-myfaces._impl._util._Utils.getChild.stripHtml = function(content) {
- return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._htmlStripper, content);
-};
-
-/**
- * Simplified encapsulation function to strip the head content from a given string
- * @param {String} content, our content to be stripped from its outer head areas
- * return the stripped content or null if no stripping was possible
- */
-myfaces._impl._util._Utils.getChild.stripHead = function(content) {
- return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._headStripper, content);
-};
-
-/**
- * Simplified encapsulation function to strip the body content from a given string
- * @param {String} content, our content to be stripped from its outer body areas
- * return the stripped content or null if no stripping was possible
- */
-myfaces._impl._util._Utils.getChild.stripBody = function(content) {
- return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._bodyStripper, content);
-};
-
-/**
- * Internal tag stripper which strips the content from a string
- * utilizing a controller
- * @param {RegExp} stripper the stripping controller
- * @param {String} content, the enclosing content
- * @return either the stripped string, or null if no stripping could be performed!
- */
-myfaces._impl._util._Utils.getChild.getTagContent = function(stripper, content) {
+ /**
+ * Simplified encapsulation function to strip the html content from a given string
+ * @param {String} content, our content to be stripped from its outer html areas
+ * return the stripped content or null if no stripping was possible
+ */
+ myfaces._impl._util._Utils.getChild.stripHtml = function(content) {
+ return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._htmlStripper, content);
+ };
+
+ /**
+ * Simplified encapsulation function to strip the head content from a given string
+ * @param {String} content, our content to be stripped from its outer head areas
+ * return the stripped content or null if no stripping was possible
+ */
+ myfaces._impl._util._Utils.getChild.stripHead = function(content) {
+ return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._headStripper, content);
+ };
+
+ /**
+ * Simplified encapsulation function to strip the body content from a given string
+ * @param {String} content, our content to be stripped from its outer body areas
+ * return the stripped content or null if no stripping was possible
+ */
+ myfaces._impl._util._Utils.getChild.stripBody = function(content) {
+ return myfaces._impl._util._Utils.getChild.getTagContent(myfaces._impl._util._Utils.getChild._bodyStripper, content);
+ };
+
+ /**
+ * Internal tag stripper which strips the content from a string
+ * utilizing a controller
+ * @param {RegExp} stripper the stripping controller
+ * @param {String} content, the enclosing content
+ * @return either the stripped string, or null if no stripping could be performed!
+ */
+ myfaces._impl._util._Utils.getChild.getTagContent = function(stripper, content) {
- if('undefined' == typeof content || null == typeof content) return null;
- stripper.exec(content);
+ if('undefined' == typeof content || null == typeof content) return null;
+ stripper.exec(content);
- var result = RegExp.$1;
- if('undefined' == typeof result || result == "") {
- return null;
- }
- return result;
-};
+ var result = RegExp.$1;
+ if('undefined' == typeof result || result == "") {
+ return null;
+ }
+ return result;
+ };
-/**
- * fetches a global config entry
- * @param {String} configName the name of the configuration entry
- * @param {Object} defaultValur
- *
- * @return either the config entry or if none is given the default value
- */
-myfaces._impl._util._Utils.getGlobalConfig = function(configName, defaultValue) {
- /*use(myfaces._impl._util)*/
- var _LangUtils = myfaces._impl._util._LangUtils;
+ /**
+ * fetches a global config entry
+ * @param {String} configName the name of the configuration entry
+ * @param {Object} defaultValur
+ *
+ * @return either the config entry or if none is given the default value
+ */
+ myfaces._impl._util._Utils.getGlobalConfig = function(configName, defaultValue) {
+ /*use(myfaces._impl._util)*/
+ var _LangUtils = myfaces._impl._util._LangUtils;
- if (_LangUtils.exists(myfaces,"config") && _LangUtils.exists(myfaces.config,configName)) {
- return myfaces.config[configName];
- }
- return defaultValue;
-};
+ if (_LangUtils.exists(myfaces,"config") && _LangUtils.exists(myfaces.config,configName)) {
+ return myfaces.config[configName];
+ }
+ return defaultValue;
+ };
-/**
- * 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._util._Utils.getLocalOrGlobalConfig = function(configName, localOptions, defaultValue) {
- /*use(myfaces._impl._util)*/
- var _LangUtils = myfaces._impl._util._LangUtils;
-
- var globalOption = myfaces._impl._util._Utils.getGlobalConfig(configName, defaultValue);
- if(!_LangUtils.exists(localOptions, "myfaces") || !_LangUtils.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
+ */
+ myfaces._impl._util._Utils.getLocalOrGlobalConfig = function(configName, localOptions, defaultValue) {
+ /*use(myfaces._impl._util)*/
+ var _LangUtils = myfaces._impl._util._LangUtils;
+
+ var globalOption = myfaces._impl._util._Utils.getGlobalConfig(configName, defaultValue);
+ if(!_LangUtils.exists(localOptions, "myfaces") || !_LangUtils.exists(localOptions.myfaces,configName)) {
+ return globalOption;
+ }
+ return localOptions.myfaces[configName];
+ };
-/**
- * Helper Regexps
- *
- * See the RI JSDocs why we provide this regexps, the jsdocs of the RI basically say
- * for the response update phase,
- * if a CDATA block of a response contains a head element we have to replace
- * the contents head with the head provided by the response
- * the same applies to content
- * Also the html must be trimmed if present!
- *
- * Wy apply precompiled regular expressions here to keep the code small
- * a linear ll(n) parser probably has somewhat better performance
- * that has to be measured, I am not sure about this, I assume for the average
- * string size we deal here it is pretty equal, not sure how good the javascript
- * engines optimize precompiled regexps, after all regexp engines also mostly
- * work on ll parsers internally!
- * One advantage however would be we probably could catch everything in one
- * internal loop insead of three...
- *
- *
- * If the performance is subpar, we always can add a stripping ll(n) parser to our mix
- * but this would produce a massiv code bloat!
- */
-myfaces._impl._util._Utils.getChild._htmlStripper = /<\s*html[^>]*>(.*)<\/\s*html[^>]*>/i;
-myfaces._impl._util._Utils.getChild._headStripper = /<\s*head[^>]*>(.*)<\/\s*head[^>]*>/i;
-myfaces._impl._util._Utils.getChild._bodyStripper = /<\s*body[^>]*>(.*)<\/\s*body[^>]*>/i;
+ /**
+ * Helper Regexps
+ *
+ * See the RI JSDocs why we provide this regexps, the jsdocs of the RI basically say
+ * for the response update phase,
+ * if a CDATA block of a response contains a head element we have to replace
+ * the contents head with the head provided by the response
+ * the same applies to content
+ * Also the html must be trimmed if present!
+ *
+ * Wy apply precompiled regular expressions here to keep the code small
+ * a linear ll(n) parser probably has somewhat better performance
+ * that has to be measured, I am not sure about this, I assume for the average
+ * string size we deal here it is pretty equal, not sure how good the javascript
+ * engines optimize precompiled regexps, after all regexp engines also mostly
+ * work on ll parsers internally!
+ * One advantage however would be we probably could catch everything in one
+ * internal loop insead of three...
+ *
+ *
+ * If the performance is subpar, we always can add a stripping ll(n) parser to our mix
+ * but this would produce a massiv code bloat!
+ */
+ myfaces._impl._util._Utils.getChild._htmlStripper = /<\s*html[^>]*>(.*)<\/\s*html[^>]*>/i;
+ myfaces._impl._util._Utils.getChild._headStripper = /<\s*head[^>]*>(.*)<\/\s*head[^>]*>/i;
+ myfaces._impl._util._Utils.getChild._bodyStripper = /<\s*body[^>]*>(.*)<\/\s*body[^>]*>/i;
-
+}
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=767890&r1=767889&r2=767890&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Thu Apr 23 11:04:51 2009
@@ -15,7 +15,7 @@
_reserveMyfacesNamespaces();
-if (!myfaces._impl._util._LangUtils.exists(myfaces, "_jsfImpl")) {
+if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.core, "_jsfImpl")) {
myfaces._impl.core._jsfImpl = function() {
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=767890&r1=767889&r2=767890&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 Thu Apr 23 11:04:51 2009
@@ -20,119 +20,124 @@
_reserveMyfacesNamespaces();
-/**
- * Constructor
- * @param {HtmlElement} source - Item that triggered the request
- * @param {Html Form} sourceForm - Form containing source
- * @param {Map} context - AJAX context
- * @param {Map} passThough - parameters to pass through to the server (execute/render)
- */
-myfaces._impl.xhrCore._AjaxRequest = function(source, sourceForm, context, passThrough) {
- this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
- try {
- this.m_contentType = "application/x-www-form-urlencoded";
- this.m_source = source;
- this.m_xhr = null;
- // myfaces parameters
- this.m_partialIdsArray = null;
- var errorlevel = 'NONE';
- this.m_queuesize = -1;
-
- /*namespace remapping for readability*/
- var _Utils = myfaces._impl._util._Utils;
- var _LangUtils = myfaces._impl._util._LangUtils;
+if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.xhrCore, "_AjaxRequest")) {
- if (_Utils.getLocalOrGlobalConfig(context,"errorlevel", null) != null) {
- errorlevel = context.myfaces.errorlevel;
- }
- if (_Utils.getLocalOrGlobalConfig(context,"queuesize", null) != null) {
- this.m_queuesize = context.myfaces.queuesize;
- }
- if (_Utils.getLocalOrGlobalConfig(context,"pps", null) != null
- && _LangUtils.exists(passThrough,myfaces._impl.core._jsfImpl._PROP_EXECUTE)
- && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
- this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
- }
-
- this.m_context = context;
- this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
- this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
- this.m_sourceForm = sourceForm;
- this.m_passThrough = passThrough;
- this.m_requestParameters = this.getViewState();
- for (var key in this.m_passThrough) {
- this.m_requestParameters = this.m_requestParameters +
- "&" + encodeURIComponent(key) +
- "=" + encodeURIComponent(this.m_passThrough[key]);
- }
- } catch (e) {
- this.m_exception.throwError(null, context, "Ctor", e);
- }
-};
+ /**
+ * Constructor
+ * @param {HtmlElement} source - Item that triggered the request
+ * @param {Html Form} sourceForm - Form containing source
+ * @param {Map} context - AJAX context
+ * @param {Map} passThough - parameters to pass through to the server (execute/render)
+ */
+ myfaces._impl.xhrCore._AjaxRequest = function(source, sourceForm, context, passThrough) {
+ this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
+ try {
+ this.m_contentType = "application/x-www-form-urlencoded";
+ this.m_source = source;
+ this.m_xhr = null;
+ // myfaces parameters
+ this.m_partialIdsArray = null;
+ var errorlevel = 'NONE';
+ this.m_queuesize = -1;
+
+ /*namespace remapping for readability*/
+ var _Utils = myfaces._impl._util._Utils;
+ var _LangUtils = myfaces._impl._util._LangUtils;
-/**
- * Sends an Ajax request
- * @param {RequestQueue} requestQueue - Queue object to trigger next request
- */
-
-myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
- try {
- if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
- // request object for Internet Explorer
- try {
- this.m_xhr = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- this.m_xhr = new ActiveXObject('Microsoft.XMLHTTP');
- }
- } else {
- // request object for standard browser
- this.m_xhr = new XMLHttpRequest();
+ if (_Utils.getLocalOrGlobalConfig(context,"errorlevel", null) != null) {
+ errorlevel = context.myfaces.errorlevel;
+ }
+ if (_Utils.getLocalOrGlobalConfig(context,"queuesize", null) != null) {
+ this.m_queuesize = context.myfaces.queuesize;
+ }
+ if (_Utils.getLocalOrGlobalConfig(context,"pps", null) != null
+ && _LangUtils.exists(passThrough,myfaces._impl.core._jsfImpl._PROP_EXECUTE)
+ && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
+ this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
+ }
+
+ this.m_context = context;
+ this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
+ this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
+ this.m_sourceForm = sourceForm;
+ this.m_passThrough = passThrough;
+ this.m_requestParameters = this.getViewState();
+ for (var key in this.m_passThrough) {
+ this.m_requestParameters = this.m_requestParameters +
+ "&" + encodeURIComponent(key) +
+ "=" + encodeURIComponent(this.m_passThrough[key]);
+ }
+ } catch (e) {
+ this.m_exception.throwError(null, context, "Ctor", e);
}
- this.m_xhr.open("POST", this.m_sourceForm.action, true);
- this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
- this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
- this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
- jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
- this.m_xhr.send(this.m_requestParameters);
- } catch (e) {
- this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
- }
-};
+ };
-/**
- * Callback method to process the Ajax response
- * triggered by RequestQueue
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.requestCallback = function() {
- var READY_STATE_DONE = 4;
- try {
-
- if (this.m_xhr.readyState == READY_STATE_DONE) {
- if (this.m_xhr.status >= 200 || this.m_xhr.status < 300) {
- jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
- jsf.ajax.response(this.m_xhr, this.m_context);
- jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS);
- myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
+ /**
+ * Sends an Ajax request
+ * @param {RequestQueue} requestQueue - Queue object to trigger next request
+ */
+
+ myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
+ try {
+ if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
+ // request object for Internet Explorer
+ try {
+ this.m_xhr = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ this.m_xhr = new ActiveXObject('Microsoft.XMLHTTP');
+ }
} else {
- jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
- jsf.ajax.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._ERROR_HTTPERROR,
- myfaces._impl.core._jsfImpl._ERROR_HTTPERROR, "Request failed with status " + this.m_xhr.status
- + " and reason " + this.getHtmlStatusText());
+ // request object for standard browser
+ this.m_xhr = new XMLHttpRequest();
+ }
+ this.m_xhr.open("POST", this.m_sourceForm.action, true);
+ this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
+ this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
+ this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
+ jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
+ this.m_xhr.send(this.m_requestParameters);
+ } catch (e) {
+ this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
+ }
+ };
+
+ /**
+ * Callback method to process the Ajax response
+ * triggered by RequestQueue
+ */
+ myfaces._impl.xhrCore._AjaxRequest.prototype.requestCallback = function() {
+ var READY_STATE_DONE = 4;
+ try {
+
+ if (this.m_xhr.readyState == READY_STATE_DONE) {
+ if (this.m_xhr.status >= 200 || this.m_xhr.status < 300) {
+ jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
+ jsf.ajax.response(this.m_xhr, this.m_context);
+ jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS);
+ myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
+ } else {
+ jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
+ jsf.ajax.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._ERROR_HTTPERROR,
+ myfaces._impl.core._jsfImpl._ERROR_HTTPERROR, "Request failed with status " + this.m_xhr.status
+ + " and reason " + this.getHtmlStatusText());
+ }
}
+ } catch (e) {
+ this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
}
- } catch (e) {
- this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
}
-}
-/**
- * Spec. 13.3.1
- * Collect and encode input elements.
- * Additionally the hidden element javax.faces.ViewState
- * @return {String} - Concatenated String of the encoded input elements
- * and javax.faces.ViewState element
- */
-myfaces._impl.xhrCore._AjaxRequest.prototype.getViewState = function() {
- return this.m_ajaxUtil.processUserEntries(this.m_xhr, this.m_context, this.m_source,
- this.m_sourceForm, this.m_partialIdsArray);
+ /**
+ * Spec. 13.3.1
+ * Collect and encode input elements.
+ * Additionally the hidden element javax.faces.ViewState
+ * @return {String} - Concatenated String of the encoded input elements
+ * and javax.faces.ViewState element
+ */
+ myfaces._impl.xhrCore._AjaxRequest.prototype.getViewState = function() {
+ return this.m_ajaxUtil.processUserEntries(this.m_xhr, this.m_context, this.m_source,
+ this.m_sourceForm, this.m_partialIdsArray);
+ }
+
+
}
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js?rev=767890&r1=767889&r2=767890&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js Thu Apr 23 11:04:51 2009
@@ -20,70 +20,73 @@
_reserveMyfacesNamespaces();
+if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.xhrCore, "_AjaxRequestQueue")) {
-/**
- * Constructor
- */
-myfaces._impl.xhrCore._AjaxRequestQueue = function() {
- this.m_request = null;
- this.m_queuedRequests = [];
- this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequestQueue", "NONE");
-};
-
-/**
- * [STATIC PROPERTIES]
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.queue = new myfaces._impl.xhrCore._AjaxRequestQueue();
-
-/**
- * [STATIC]
- * provides api callback
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback = function() {
- if (myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request != null) {
- myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.requestCallback();
- } else {
- myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_exception.throwWarning
- (null, null, "doRequestCallback", "No request object available");
- }
-};
-
-/**
- * send a reuest or keeps it in a queue
- * @param {myfaces._impl.xhrCore._AjaxRequest} request - request to send
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.prototype.queueRequest = function(request) {
- if (this.m_request == null) {
- this.m_request = request;
- this.m_request.send();
- } else {
- this.m_queuedRequests.push(request);
- if (request.m_queuesize > -1 && request.m_queuesize < this.m_queuedRequests.length)
- this.m_queuedRequests.shift();
- }
-};
-
-/**
- * process queue, send request, if exists
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.prototype.processQueue = function() {
- if (this.m_queuedRequests.length > 0) {
- // Using Javascripts build-in queue capabilities here!
- // JSF RI is using Delayed Shift Queue (DSQ), which starts to outperform the build-in queue
- // when queue size exceeds ~10 requests (http://safalra.com/web-design/javascript/queues/).
- // With JSF Ajax the queue will hardly ever reach this size.
- this.m_request = this.m_queuedRequests.shift();
- this.m_request.send();
- } else {
+ /**
+ * Constructor
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue = function() {
this.m_request = null;
- }
-};
+ this.m_queuedRequests = [];
+ this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequestQueue", "NONE");
+ };
+
+ /**
+ * [STATIC PROPERTIES]
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue.queue = new myfaces._impl.xhrCore._AjaxRequestQueue();
+
+ /**
+ * [STATIC]
+ * provides api callback
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback = function() {
+ if (myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request != null) {
+ myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_request.requestCallback();
+ } else {
+ myfaces._impl.xhrCore._AjaxRequestQueue.queue.m_exception.throwWarning
+ (null, null, "doRequestCallback", "No request object available");
+ }
+ };
+
+ /**
+ * send a reuest or keeps it in a queue
+ * @param {myfaces._impl.xhrCore._AjaxRequest} request - request to send
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue.prototype.queueRequest = function(request) {
+ if (this.m_request == null) {
+ this.m_request = request;
+ this.m_request.send();
+ } else {
+ this.m_queuedRequests.push(request);
+ if (request.m_queuesize > -1 && request.m_queuesize < this.m_queuedRequests.length)
+ this.m_queuedRequests.shift();
+ }
+ };
+
+ /**
+ * process queue, send request, if exists
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue.prototype.processQueue = function() {
+ if (this.m_queuedRequests.length > 0) {
+ // Using Javascripts build-in queue capabilities here!
+ // JSF RI is using Delayed Shift Queue (DSQ), which starts to outperform the build-in queue
+ // when queue size exceeds ~10 requests (http://safalra.com/web-design/javascript/queues/).
+ // With JSF Ajax the queue will hardly ever reach this size.
+ this.m_request = this.m_queuedRequests.shift();
+ this.m_request.send();
+ } else {
+ this.m_request = null;
+ }
+ };
+
+ /**
+ * cleanup queue
+ */
+ myfaces._impl.xhrCore._AjaxRequestQueue.prototype.clearQueue = function() {
+ this.m_request = null;
+ this.m_queuedRequest = null;
+ this.m_requestPending = false;
+ };
-/**
- * cleanup queue
- */
-myfaces._impl.xhrCore._AjaxRequestQueue.prototype.clearQueue = function() {
- this.m_request = null;
- this.m_queuedRequest = null;
- this.m_requestPending = false;
-};
\ No newline at end of file
+}
\ No newline at end of file