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 2011/09/14 14:56:05 UTC
svn commit: r1170583 [1/3] - in /myfaces/core/branches/2.0.x/api/src:
assembler/ main/javascript/META-INF/resources/myfaces/_impl/_util/
main/javascript/META-INF/resources/myfaces/_impl/core/
main/javascript/META-INF/resources/myfaces/_impl/xhrCore/ ma...
Author: werpu
Date: Wed Sep 14 12:56:05 2011
New Revision: 1170583
URL: http://svn.apache.org/viewvc?rev=1170583&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-3305
Added:
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_EvalHandlers.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/BaseRequest.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/FormData.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/Xhr1.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/XhrConst.js
Modified:
myfaces/core/branches/2.0.x/api/src/assembler/jsdoc-compiler.xml
myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml
myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-compiler.xml
myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_FinalizeableObj.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js
myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsdoc-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsdoc-compiler.xml?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsdoc-compiler.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsdoc-compiler.xml Wed Sep 14 12:56:05 2011
@@ -18,34 +18,42 @@
<includes>
<include>**/api/jsf.js</include>
+ <include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
+
<include>**/_impl/i18n/Messages.js</include>
+
<include>**/_impl/i18n/Messages_de.js</include>
+ <include>**/_impl/i18n/Messages_nl.js</include>
<include>**/_impl/i18n/Messages_es.js</include>
<include>**/_impl/i18n/Messages_fr.js</include>
<include>**/_impl/i18n/Messages_it.js</include>
- <include>**/_impl/i18n/Messages_nl.js</include>
<include>**/_impl/i18n/Messages_ru.js</include>
-
<include>**/_impl/_util/_Lang.js</include>
- <include>**/_impl/_util/_Dom.js</include>
<include>**/_impl/_util/_Queue.js</include>
<include>**/_impl/_util/_ListenerQueue.js</include>
+ <include>**/_impl/_util/_Dom.js</include>
<include>**/_impl/_util/_HtmlStripper.js</include>
-
<include>**/_impl/xhrCore/_FinalizeableObj.js</include>
+
<include>**/_impl/xhrCore/_AjaxUtils.js</include>
<include>**/_impl/xhrCore/_AjaxRequestQueue.js</include>
- <include>**/_impl/xhrCore/_BaseRequest.js</include>
- <include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <!-- this is pure 2.1 functionality -->
- <include>**/_impl/xhrCore/_IFrameRequest.js</include>
+ <!-- the jsf.js independend xhr core engine -->
+ <include>**/_impl/xhrCore/engine/XhrConst.js</include>
+ <include>**/_impl/xhrCore/engine/FormData.js</include>
+ <include>**/_impl/xhrCore/engine/BaseRequest.js</include>
+ <include>**/_impl/xhrCore/engine/Xhr1.js</include>
+ <include>**/_impl/xhrCore/engine/IFrame.js</include>
+ <include>**/_impl/xhrCore/_AjaxRequest.js</include>
+ <!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
+ <include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
<include>**/_impl/core/Impl.js</include>
+
</includes>
Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-compiler.xml Wed Sep 14 12:56:05 2011
@@ -40,11 +40,17 @@
<script>
<fileName>jsf.js</fileName>
<includes>
+ <include>**/_impl/core/_EvalHandlers.js</include>
+
<include>**/_impl/core/_Runtime.js</include>
<include>**/_impl/i18n/Messages.js</include>
<include>**/_impl/i18n/Messages_de.js</include>
<include>**/_impl/i18n/Messages_nl.js</include>
+ <include>**/_impl/i18n/Messages_fr.js</include>
+ <include>**/_impl/i18n/Messages_it.js</include>
+ <include>**/_impl/i18n/Messages_es.js</include>
+ <include>**/_impl/i18n/Messages_ru.js</include>
<include>**/_impl/_util/_Lang.js</include>
<include>**/_impl/_util/_Queue.js</include>
@@ -56,10 +62,18 @@
<include>**/_impl/xhrCore/_FinalizeableObj.js</include>
<include>**/_impl/xhrCore/_AjaxUtils.js</include>
<include>**/_impl/xhrCore/_AjaxRequestQueue.js</include>
- <include>**/_impl/xhrCore/_BaseRequest.js</include>
+
+ <!-- the jsf.js independend xhr core engine -->
+ <include>**/_impl/xhrCore/engine/XhrConst.js</include>
+ <include>**/_impl/xhrCore/engine/FormData.js</include>
+ <include>**/_impl/xhrCore/engine/BaseRequest.js</include>
+ <include>**/_impl/xhrCore/engine/Xhr1.js</include>
+ <include>**/_impl/xhrCore/engine/IFrame.js</include>
+
+
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
- <!-- this is pure 2.1 functionality -->
+ <!-- this is pure 2.2 functionality -->
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-compiler.xml?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-compiler.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-compiler.xml Wed Sep 14 12:56:05 2011
@@ -40,6 +40,7 @@
<script>
<fileName>jsf-uncompressed.js</fileName>
<includes>
+ <include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
<include>**/_impl/core/jsf-uncompressed.js</include>
</includes>
Modified: myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml (original)
+++ myfaces/core/branches/2.0.x/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml Wed Sep 14 12:56:05 2011
@@ -41,6 +41,7 @@
<script>
<fileName>jsf-uncompressed-full.js</fileName>
<includes>
+ <include>**/_impl/core/_EvalHandlers.js</include>
<include>**/_impl/core/_Runtime.js</include>
<include>**/_impl/i18n/Messages.js</include>
@@ -64,7 +65,14 @@
<include>**/_impl/xhrCore/_AjaxUtils.js</include>
<include>**/_impl/xhrCore/_AjaxRequestQueue.js</include>
- <include>**/_impl/xhrCore/_BaseRequest.js</include>
+
+ <!-- the jsf.js independend xhr core engine -->
+ <include>**/_impl/xhrCore/engine/XhrConst.js</include>
+ <include>**/_impl/xhrCore/engine/FormData.js</include>
+ <include>**/_impl/xhrCore/engine/BaseRequest.js</include>
+ <include>**/_impl/xhrCore/engine/Xhr1.js</include>
+ <include>**/_impl/xhrCore/engine/IFrame.js</include>
+
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
<!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
<include>**/_impl/xhrCore/_IFrameRequest.js</include>
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Wed Sep 14 12:56:05 2011
@@ -203,7 +203,7 @@ myfaces._impl.core._Runtime.singletonExt
nodeIdOrName: function(elem) {
if (elem) {
//just to make sure that the pas
- var origElemIdentifier = elem;
+
elem = this.byId(elem);
if(!elem) return null;
//detached element handling, we also store the element name
@@ -240,6 +240,15 @@ myfaces._impl.core._Runtime.singletonExt
this._removeNode(item, false);
},
+ createElement: function(nodeName, attrs) {
+ var ret = document.createElement(nodeName);
+ if(attrs) {
+ for(var key in attrs) {
+ this.setAttribute(ret, key, attrs[key]);
+ }
+ }
+ return ret;
+ },
/**
* Checks whether the browser is dom compliant.
@@ -286,8 +295,6 @@ myfaces._impl.core._Runtime.singletonExt
if (markup !== "") {
var ret = null;
- //w3c compliant browsers with proper contextual fragments
- var parentNode;
// we try to determine the browsers compatibility
// level to standards dom level 2 via various methods
if (this.isDomCompliant()) {
@@ -318,7 +325,7 @@ myfaces._impl.core._Runtime.singletonExt
/**
* detchaes a set of nodes from their parent elements
* in a browser independend manner
- * @param {Nodelist} items the items which need to be detached
+ * @param {Object} items the items which need to be detached
* @return {Array} an array of nodes with the detached dom nodes
*/
detach: function(items) {
@@ -333,9 +340,9 @@ myfaces._impl.core._Runtime.singletonExt
}
//all ies treat node lists not as arrays so we have to take
//an intermediate step
- var items = this._Lang.objToArray(items);
- for(var cnt = 0; cnt < items.length; cnt++) {
- ret.push(items[cnt].parentNode.removeChild(items[cnt]));
+ var nodeArr = this._Lang.objToArray(items);
+ for(var cnt = 0; cnt < nodeArr.length; cnt++) {
+ ret.push(nodeArr[cnt].parentNode.removeChild(nodeArr[cnt]));
}
return ret;
},
@@ -416,8 +423,6 @@ myfaces._impl.core._Runtime.singletonExt
var dummyPlaceHolder = this.getDummyPlaceHolder();
//now that Microsoft has finally given
//ie a working gc in 8 we can skip the costly operation
- var b = myfaces._impl.core._Runtime.browser;
-
if (b.isIE && b.isIE < 8) {
this._removeChildNodes(dummyPlaceHolder, false);
}
@@ -498,7 +503,7 @@ myfaces._impl.core._Runtime.singletonExt
//we have customers using html unit, this has a bug in the table resolution
//hence we determine the depth dynamically
var depth = this._determineDepth(probe);
- var newProbe = probe;
+
this._removeChildNodes(probe, false);
probe.innerHTML = "";
@@ -568,7 +573,7 @@ myfaces._impl.core._Runtime.singletonExt
try {
//outer HTML setting is only possible in earlier IE versions all modern browsers throw an exception here
//again to speed things up we precheck first
- if(!this._isTableElement(childNode)) {
+ if(!this._isTableElement(node)) {
//we do not do a table structure innnerhtml on table elements except td
//htmlunit rightfully complains that we should not do it
node.innerHTML = "";
@@ -588,6 +593,9 @@ myfaces._impl.core._Runtime.singletonExt
// both innerHTML and outerHTML fails when <tr> is the node, but in that case
// we need to force node removal, otherwise it will be on the tree (IE 7 IE 6)
this.detach(node);
+ if (!b.isIEMobile) {
+ delete node;
+ }
} catch (e1) {
}
}
@@ -1147,12 +1155,14 @@ myfaces._impl.core._Runtime.singletonExt
}
//before going into the more complicated stuff we try the simple approach
+ var ret = null;
+ var elemForm = null;
if (!this._Lang.isString(elem)) {
//html 5 allows finally the detachement of elements
//by introducing a form attribute
- var elemForm = this.html5FormDetection(elem);
+ elemForm = this.html5FormDetection(elem);
if (elemForm) {
return elemForm;
}
@@ -1164,7 +1174,7 @@ myfaces._impl.core._Runtime.singletonExt
if (this._Lang.equalsIgnoreCase(elem.tagName, "form")) {
return elem;
}
- var ret = this.getParent(elem, "form");
+ ret = this.getParent(elem, "form");
if (ret) return ret;
} else {
elem = this.byId(elem);
@@ -1172,7 +1182,7 @@ myfaces._impl.core._Runtime.singletonExt
if (!elem){
return null;
}
- var ret = this.getParent(elem, "form");
+ ret = this.getParent(elem, "form");
if (ret) return ret;
}
@@ -1186,7 +1196,7 @@ myfaces._impl.core._Runtime.singletonExt
if (id && '' != id) {
//we have to assert that the element passed down is detached
var domElement = this.byId(id);
- var elemForm = this.html5FormDetection(domElement);
+ elemForm = this.html5FormDetection(domElement);
if (elemForm) {
return elemForm;
}
@@ -1442,7 +1452,7 @@ myfaces._impl.core._Runtime.singletonExt
isManualScriptEval: function() {
if (!this._Lang.exists(myfaces, "config._autoeval")) {
- var _Browser = this._RT.browser;
+
//now we rely on the document being processed if called for the first time
var evalDiv = document.createElement("div");
this._Lang.reserveNamespace("myfaces.config._autoeval");
@@ -1530,7 +1540,7 @@ myfaces._impl.core._Runtime.singletonExt
}
,
- getDummyPlaceHolder: function(markup) {
+ getDummyPlaceHolder: function() {
var created = false;
if (!this._dummyPlaceHolder) {
this._dummyPlaceHolder = document.createElement("div");
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js Wed Sep 14 12:56:05 2011
@@ -33,7 +33,6 @@
* @namespace
* @name _util
*/
-(myfaces._impl._util) ? myfaces._impl._util: {};
@@ -42,6 +41,7 @@
* @name _Lang
* @memberOf myfaces._impl._util
* @extends myfaces._impl.core._Runtime
+ * @namespace
* @description Object singleton for Language related methods, this object singleton
* decorates the namespace myfaces._impl.core._Runtime and adds a bunch of new methods to
* what _Runtime provided
@@ -257,46 +257,9 @@ var _Lang = myfaces._impl.core._Runtime.
},
/**
- * 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 {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 {int} offset the location in obj to start iterating from. Defaults to 0.
- Optional.
- * @param {Array} packArr 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.
- */
- /*_toArray : function(obj, offset, packArr) {
- // summary:
- // Converts an array-like object (i.e. arguments, DOMCollection) to an
- // array. Returns a new Array with the elements of obj.
- // obj:
- // the object to "arrayify". We expect the object to have, at a
- // minimum, a length property which corresponds to integer-indexed
- // properties.
- // offset:
- // the location in obj to start iterating from. Defaults to 0.
- // Optional.
- // 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.
- var arr = packArr || [];
- //TODO add splicing here
-
- for (var x = offset || 0; x < obj.length; x++) {
- arr.push(obj[x]);
- }
- return arr; // Array
- }, */
-
- /**
* 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
+ * @param {String} it the string to be trimmed
+ * @param {RegExp} splitter the splitter regular expressiion
*
* FIXME is this still used?
*/
@@ -340,7 +303,9 @@ var _Lang = myfaces._impl.core._Runtime.
str = str.replace(/^\s\s*/, '');
var ws = /\s/;
var i = str.length;
- while (ws.test(str.charAt(--i)));
+ while (ws.test(str.charAt(--i))){
+ //do nothing
+ }
return str.slice(0, i + 1);
},
@@ -431,50 +396,36 @@ var _Lang = myfaces._impl.core._Runtime.
/**
* Helper function to merge two maps
* into one
- * @param {|Object|} dest the destination map
- * @param {|Object|} src the source map
- * @param {|boolean|} overwrite if set to true the destination is overwritten if the keys exist in both maps
+ * @param {Object} dest the destination map
+ * @param {Object} src the source map
+ * @param {boolean} overwrite if set to true the destination is overwritten if the keys exist in both maps
**/
- mixMaps : function(dest, src, overwrite, blockFilter) {
- if (!dest || !src) {
+ mixMaps: function(dest, src, overwrite, blockFilter, whitelistFilter) {
+ if (!dest || !src) {
throw Error(this.getMessage("ERR_PARAM_MIXMAPS",null,"_Lang.mixMaps"));
- }
+ }
+ var _undef = "undefined";
+ for (var key in src) {
+ if(blockFilter && blockFilter[key]) {
+ continue;
+ }
+ if(whitelistFilter && !whitelistFilter[key]) {
+ continue;
+ }
+ if (!overwrite) {
- /**
- * mixing code depending on the state of dest and the overwrite param
- */
- var ret = {};
- var keyIdx = {};
- var key = null;
- var _undef = "undefined";
- for (key in src) {
- if(blockFilter && blockFilter[key]) {
- continue;
- }
- /**
- *we always overwrite dest with source
- *unless overWrite is not set or source does not exist
- *but also only if dest exists otherwise source still is taken
- */
- if (!overwrite) {
/**
*we use exists instead of booleans because we cannot rely
*on all values being non boolean, we would need an elvis
*operator in javascript to shorten this :-(
*/
- ret[key] = (_undef != typeof dest[key]) ? dest[key] : src[key];
+ dest[key] = (_undef != typeof dest[key]) ? dest[key] : src[key];
} else {
- ret[key] = (_undef != typeof src[key]) ? src[key] : dest[key];
+ dest[key] = (_undef != typeof src[key]) ? src[key] : dest[key];
}
- keyIdx[key] = true;
- }
- for (key in dest) {
- /*if result.key does not exist we push in dest.key*/
- ret[key] = (_undef != typeof ret[key]) ? ret[key] : dest[key];
- }
- return ret;
- }
- ,
+ }
+ return dest;
+ },
/**
* checks if an array contains an element
@@ -565,8 +516,13 @@ var _Lang = myfaces._impl.core._Runtime.
* @param arr the array to filter
* @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality
* function (element<,key, array>)
- * @param startPos (optional) the starting position
- * @param scope (optional) the scope to apply the closure to
+ * <p />
+ * optional params
+ * <p />
+ * <ul>
+ * <li>param startPos (optional) the starting position </li>
+ * <li>param scope (optional) the scope to apply the closure to </li>
+ * </ul>
*/
arrForEach: function(arr, func /*startPos, scope*/) {
if(!arr || !arr.length ) return;
@@ -606,9 +562,12 @@ var _Lang = myfaces._impl.core._Runtime.
* @param arr the array to filter
* @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality
* function (element<,key, array>)
- * @param startPos (optional) the starting position
- * @param scope (optional) the scope to apply the closure to
- *
+ * <p />
+ * additional params
+ * <ul>
+ * <li> startPos (optional) the starting position</li>
+ * <li> scope (optional) the scope to apply the closure to</li>
+ * </ul>
*/
arrFilter: function(arr, func /*startPos, scope*/) {
if(!arr || !arr.length ) return [];
@@ -627,11 +586,12 @@ var _Lang = myfaces._impl.core._Runtime.
startPos = (startPos < 0) ? Math.ceil(startPos) : Math.floor(startPos);
for (var cnt = startPos; cnt < arr.length; cnt++) {
+ var elem = null;
if (thisObj) {
- var elem = arr[cnt];
+ elem = arr[cnt];
if (func.call(thisObj, elem, cnt, arr)) ret.push(elem);
} else {
- var elem = arr[cnt];
+ elem = arr[cnt];
if (func(arr[cnt], cnt, arr)) ret.push(elem);
}
}
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js Wed Sep 14 12:56:05 2011
@@ -78,8 +78,7 @@ myfaces._impl.core._Runtime.extendClass(
* @param {Object} argument, the arguments passed down which are broadcast
*/
broadcastEvent : function(argument) {
- var _Lang = myfaces._impl._util._Lang;
- var _args = _Lang.objToArray(arguments);
+ var _args = myfaces._impl._util._Lang.objToArray(arguments);
var broadCastFunc = function(element) {
element.apply(null, _args);
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js Wed Sep 14 12:56:05 2011
@@ -91,7 +91,7 @@ myfaces._impl.core._Runtime.singletonExt
* find the javax.faces.ViewState element and encode its value as well!
* return a concatenated string of the encoded values!
*
- * @throws error in case of the given element not being of type form!
+ * @throws Error in case of the given element not being of type form!
* https://issues.apache.org/jira/browse/MYFACES-2110
*/
getViewState : function(form) {
@@ -147,7 +147,6 @@ myfaces._impl.core._Runtime.singletonExt
**/
var _Lang = this._Lang;
var _Dom = this._Dom;
- var getConfig = myfaces._impl.core._Runtime.getLocalOrGlobalConfig;
/*assert if the onerror is set and once if it is set it must be of type function*/
_Lang.assertType(options.onerror, "function");
Added: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_EvalHandlers.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_EvalHandlers.js?rev=1170583&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_EvalHandlers.js (added)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_EvalHandlers.js Wed Sep 14 12:56:05 2011
@@ -0,0 +1,135 @@
+/**
+ * @namespace
+ * @name window
+ * @description supplimental window methods.
+ */
+
+if (!window.myfaces) {
+ /**
+ * @namespace
+ * @name myfaces
+ */
+ var myfaces = new function() {
+ };
+ window.myfaces = myfaces;
+}
+
+/**
+ * @memberOf myfaces
+ * @namespace
+ * @name _impl
+ */
+myfaces._impl = (myfaces._impl) ? myfaces._impl : {};
+/**
+ * @memberOf myfaces._impl
+ * @namespace
+ * @name core
+ */
+myfaces._impl.core = (myfaces._impl.core) ? myfaces._impl.core :{};
+
+if (!myfaces._impl.core._EvalHandlers) {
+ /**
+ * @memberOf myfaces._impl.core
+ * @namespace
+ * @name _EvalHandlers
+ */
+ myfaces._impl.core._EvalHandlers = new function() {
+ //the rest of the namespaces can be handled by our namespace feature
+ //helper to avoid unneeded hitches
+ /**
+ * @borrows myfaces._impl.core._Runtime as _T
+ */
+ var _T = this;
+
+ /*cascaded eval methods depending upon the browser*/
+
+ /**
+ * @function
+ * @param code
+
+ *
+ * evals a script globally using exec script (ie6 fallback)
+ * @param {String} code the code which has to be evaluated
+ * @borrows myfaces._impl.core._Runtime as _T
+ */
+ _T._evalExecScript = function(code) {
+ //execScript definitely only for IE otherwise we might have a custom
+ //window extension with undefined behavior on our necks
+ //window.execScript does not return anything
+ //on htmlunit it return "null object"
+ var ret = window.execScript(code);
+ if ('undefined' != typeof ret && ret == "null" /*htmlunit bug*/) {
+ return null;
+ }
+ return ret;
+ };
+
+ /**
+ * flakey head appendix method which does not work in the correct
+ * order or at all for all modern browsers
+ * but seems to be the only method which works on blackberry correctly
+ * hence we are going to use it as fallback
+ *
+ * @param {String} code the code part to be evaled
+ * @borrows myfaces._impl.core._Runtime as _T
+ */
+ _T._evalBBOld = function(code) {
+ var location = document.getElementsByTagName("head")[0] || document.documentElement;
+ var placeHolder = document.createElement("script");
+ placeHolder.type = "text/javascript";
+ placeHolder.text = code;
+ location.insertBefore(placeHolder, location.firstChild);
+ location.removeChild(placeHolder);
+ return null;
+ };
+
+ /**
+ * @name myfaces._impl.core._Runtime._standardGlobalEval
+ * @private
+ * @param {String} code
+ */
+ _T._standardGlobalEval = function(code) {
+ //fix which works in a cross browser way
+ //we used to scope an anonymous function
+ //but I think this is better
+ //the reason is firefox applies a wrong scope
+ //if we call eval by not scoping
+
+ var gEval = function () {
+
+ var ret = window.eval.call(window, code);
+ if ('undefined' == typeof ret) return null;
+ return ret;
+ };
+ var ret = gEval();
+ if ('undefined' == typeof ret) return null;
+ return ret;
+ };
+
+ /**
+ * global eval on scripts
+ * @param {String} code
+ * @name myfaces._impl.core._Runtime.globalEval
+ * @function
+ */
+ _T.globalEval = function(code) {
+ //TODO add a config param which allows to evaluate global scripts even if the call
+ //is embedded in an iframe
+ //We lazy init the eval type upon the browsers
+ //capabilities
+ if ('undefined' == typeof _T._evalType) {
+ _T._evalType = window.execScript ? "_evalExecScript" : null;
+ _T._evalType = !_T._evalType && window.eval && (!_T.browser.isBlackBerry || _T.browser.isBlackBerry >= 6) ? "_standardGlobalEval" : null;
+ _T._evalType = (window.eval && !_T._evalType) ? "_evalBBOld" : null;
+ }
+ if (_T._evalType) {
+ return _T[_T._evalType](code);
+ }
+ //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
+ eval.call(window, code);
+ return null;
+ };
+
+ };
+}
\ No newline at end of file
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Wed Sep 14 12:56:05 2011
@@ -34,36 +34,9 @@
*/
/** @namespace myfaces._impl.core._Runtime*/
-/**
-* @namespace
-* @name window
-* @description supplimental window methods.
-*/
-
-if(!window.myfaces) {
- /**
- * @namespace
- * @name myfaces
- */
- var myfaces = new function() {};
- window.myfaces = myfaces;
-}
-
-
-/**
-* @memberOf myfaces
-* @namespace
-* @name _impl
-*/
-myfaces._impl = (myfaces._impl) ? myfaces._impl : {};
-/**
- * @memberOf myfaces._impl
- * @namespace
- * @name core
- */
myfaces._impl.core = (myfaces._impl.core) ? myfaces._impl.core : {};
//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
@@ -96,94 +69,14 @@ if (!myfaces._impl.core._Runtime) {
*/
this._classReplacementCnt = 0;
- /*cascaded eval methods depending upon the browser*/
-
- /**
- * @function
- * @param code
-
- *
- * evals a script globally using exec script (ie6 fallback)
- * @param {String} code the code which has to be evaluated
- * @borrows myfaces._impl.core._Runtime as _T
- */
- _T._evalExecScript = function(code) {
- //execScript definitely only for IE otherwise we might have a custom
- //window extension with undefined behavior on our necks
- //window.execScript does not return anything
- //on htmlunit it return "null object"
- var ret = window.execScript(code);
- if ('undefined' != typeof ret && ret == "null" /*htmlunit bug*/) {
- return null;
- }
- return ret;
- };
-
- /**
- * flakey head appendix method which does not work in the correct
- * order or at all for all modern browsers
- * but seems to be the only method which works on blackberry correctly
- * hence we are going to use it as fallback
- *
- * @param {String} code the code part to be evaled
- * @borrows myfaces._impl.core._Runtime as _T
- */
- _T._evalBBOld = function(code) {
- var location = document.getElementsByTagName("head")[0] || document.documentElement;
- var placeHolder = document.createElement("script");
- placeHolder.type = "text/javascript";
- placeHolder.text = code;
- location.insertBefore(placeHolder, location.firstChild);
- location.removeChild(placeHolder);
- return null;
- };
-
- /**
- * @name myfaces._impl.core._Runtime._standardGlobalEval
- * @private
- * @param {String} code
- */
- _T._standardGlobalEval = function(code) {
- //fix which works in a cross browser way
- //we used to scope an anonymous function
- //but I think this is better
- //the reason is firefox applies a wrong scope
- //if we call eval by not scoping
-
- var gEval = function () {
-
- var ret = window.eval.call(window, code);
- if ('undefined' == typeof ret) return null;
- return ret;
- };
- var ret = gEval();
- if ('undefined' == typeof ret) return null;
- return ret;
- };
-
/**
* global eval on scripts
- * @param {String} code
+ * @param {String} code
* @name myfaces._impl.core._Runtime.globalEval
* @function
*/
_T.globalEval = function(code) {
- //TODO add a config param which allows to evaluate global scripts even if the call
- //is embedded in an iframe
- //We lazy init the eval type upon the browsers
- //capabilities
- if ('undefined' == typeof _T._evalType) {
- _T._evalType = window.execScript ? "_evalExecScript" : null;
- _T._evalType = !_T._evalType && window.eval && (!_T.browser.isBlackBerry || _T.browser.isBlackBerry >= 6) ? "_standardGlobalEval" : null;
- _T._evalType = (window.eval && !_T._evalType) ? "_evalBBOld" : null;
- }
- if (_T._evalType) {
- return _T[_T._evalType](code);
- }
- //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
- eval.call(window, code);
- return null;
+ return myfaces._impl.core._EvalHandlers.globalEval(code);
};
/**
@@ -194,7 +87,7 @@ if (!myfaces._impl.core._Runtime) {
* which the namespace points to, hence this function
*
* @param {String} nms the namespace to be assigned to
- * @param {Any} obj the object to be assigned
+ * @param {Object} obj the object to be assigned
* @name myfaces._impl.core._Runtime.applyToGlobalNamespace
* @function
*/
@@ -381,14 +274,14 @@ if (!myfaces._impl.core._Runtime) {
* myfacesScriptRoot to the root of your script files (aka under normal circumstances
* resources/scripts)
*
- * @param {String}Â nms, the subnamespace to be required
+ * @param {String} nms the subnamespace to be required
*/
this.require = function(nms) {
//namespace exists
if (_T.exists(nms)) return;
var rootPath = _T.getGlobalConfig("myfacesScriptRoot", "");
_T.loadScriptEval(rootPath + "/" + nms.replace(/\./g, "/") + ".js");
- },
+ };
/**
* fetches a global config entry
@@ -397,17 +290,17 @@ if (!myfaces._impl.core._Runtime) {
*
* @return either the config entry or if none is given the default value
*/
- this.getGlobalConfig = function(configName, defaultValue) {
- /**
- * note we could use exists but this is an heavy operation, since the config name usually
- * given this function here is called very often
- * is a single entry without . in between we can do the lighter shortcut
- */
- return (myfaces["config"] && 'undefined' != typeof myfaces.config[configName] ) ?
- myfaces.config[configName]
- :
- defaultValue;
- };
+ this.getGlobalConfig = function(configName, defaultValue) {
+ /**
+ * note we could use exists but this is an heavy operation, since the config name usually
+ * given this function here is called very often
+ * is a single entry without . in between we can do the lighter shortcut
+ */
+ return (myfaces["config"] && 'undefined' != typeof myfaces.config[configName] ) ?
+ myfaces.config[configName]
+ :
+ defaultValue;
+ };
/**
* gets the local or global options with local ones having higher priority
@@ -464,12 +357,12 @@ if (!myfaces._impl.core._Runtime) {
//we now check the xhr level
//sendAsBinary = 1.5 which means mozilla only
//upload attribute present == level2
- /*
- if (!_T.XHR_LEVEL) {
- var _e = _T.exists;
- _T.XHR_LEVEL = (_e(_ret, "sendAsBinary")) ? 1.5 : 1;
- _T.XHR_LEVEL = (_e(_ret, "upload") && 'undefined' != typeof FormData) ? 2 : _T.XHR_LEVEL;
- }*/
+
+ if (!_T.XHR_LEVEL) {
+ var _e = _T.exists;
+ _T.XHR_LEVEL = (_e(_ret, "sendAsBinary")) ? 1.5 : 1;
+ _T.XHR_LEVEL = (_e(_ret, "upload") && 'undefined' != typeof FormData) ? 2 : _T.XHR_LEVEL;
+ }
return _ret;
}
//IE
@@ -543,8 +436,7 @@ if (!myfaces._impl.core._Runtime) {
//ok this is nasty we have to do a head modification for ie pre 8
//the rest can be finely served with body
- var d = _T.browser;
- var position = "head"
+ var position = "head";
try {
var holder = document.getElementsByTagName(position)[0];
@@ -619,10 +511,10 @@ if (!myfaces._impl.core._Runtime) {
*
* @param {String} newCls the new class name to be generated
* @param {Object} delegateObj the delegation object
- * @param {Map} protoFuncs the prototype functions which should be attached
- * @param {Map} nmsFuncs the namespace functions which should be attached to the namespace
+ * @param {Object} protoFuncs the prototype functions which should be attached
+ * @param {Object} nmsFuncs the namespace functions which should be attached to the namespace
*/
- this.delegateObj = function( newCls, delegateObj, protoFuncs, nmsFuncs) {
+ this.delegateObj = function(newCls, delegateObj, protoFuncs, nmsFuncs) {
if (!_T.isString(newCls)) {
throw Error("new class namespace must be of type String");
}
@@ -805,14 +697,12 @@ if (!myfaces._impl.core._Runtime) {
return _T.extendClass(classNms, preserveNMS, protoFuncs);
} else {
- //TODO constructor mapping?
if (protoFuncs.constructor_) {
- //TODO needs testing if this works!
newCls.prototype.constructor = protoFuncs.constructor_;
}
_applyFuncs(oldClass, protoFuncs, true);
}
- },
+ };
/**
* Extends a class and puts a singleton instance at the reserved namespace instead
@@ -822,9 +712,9 @@ if (!myfaces._impl.core._Runtime) {
* @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) {
- return _makeSingleton(_T.extendClass, newCls, extendsCls, protoFuncs, nmsFuncs);
- };
+ this.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) {
+ return _makeSingleton(_T.extendClass, newCls, extendsCls, protoFuncs, nmsFuncs);
+ };
/**
* delegation pattern which attached singleton generation
@@ -966,6 +856,7 @@ if (!myfaces._impl.core._Runtime) {
tv = parseFloat(dav);
_T.browser = {};
+ myfaces._impl.core._EvalHandlers.browser = _T.browser;
var d = _T.browser;
if (dua.indexOf("Opera") >= 0) {
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Wed Sep 14 12:56:05 2011
@@ -38,7 +38,15 @@ if (!window.jsf) {
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_FinalizeableObj.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxUtils.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQueue.js']}", null, null, "UTF-8", false);
- _ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_BaseRequest.js']}", null, null, "UTF-8", false);
+
+
+ //_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_BaseRequest.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore.engine:_XhrConst.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore.engine:FormData.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore.engine:Xhr1.js']}", null, null, "UTF-8", false);
+ _ls("#{resource['org.apache.myfaces.core.impl.xhrCore.engine:IFrame.js']}", null, null, "UTF-8", false);
+
+
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_IFrameRequest.js']}", null, null, "UTF-8", false);
_ls("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8", false);
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Wed Sep 14 12:56:05 2011
@@ -19,7 +19,7 @@
* with partial page submit functionality, and jsf
* ppr request and timeout handling capabilities
*
- * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
+ * Author: Werner Punz (latest modification by $Author: ganeshpuri $)
* Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
*/
@@ -27,205 +27,329 @@
* @class
* @name _AjaxRequest
* @memberOf myfaces._impl.xhrCore
- * @extends myfaces._impl.xhrCore._BaseRequest
+ * @extends myfaces._impl.xhrCore._FinalizeableObj
*/
-myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", myfaces._impl.xhrCore._BaseRequest,
-/** myfaces._impl.xhrCore._AjaxRequest.prototype */
-{
- /**
- * Constructor
- * <p />
- * note there is a load of common properties
- * inherited by the base class which define the corner
- * parameters and the general internal behavior
- * like _onError etc...
- * @param {Map} an arguments map which an override any of the given protected
- * instance variables, by a simple name value pair combination
- */
- constructor_: function(arguments) {
-
- try {
- this._callSuper("constructor", arguments);
- /*namespace remapping for readability*/
- //we fetch in the standard arguments
- //and apply them to our protected attributes
- this._Lang.applyArgs(this, arguments);
-
- //if our response handler is not set
- if (!this._response) {
- this._response = new myfaces._impl.xhrCore._AjaxResponse(this._onException, this._onWarning);
- }
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", myfaces._impl.xhrCore._FinalizeableObj,
+ /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */
+ {
+
+ _contentType: "application/x-www-form-urlencoded",
+ /** source element issuing the request */
+ _source: null,
+ /** encoding for the submit */
+ _encoding:null ,
+ /** context passed down from the caller */
+ _context:null,
+ /** source form issuing the request */
+ _sourceForm: null,
+ /** passthrough parameters */
+ _passThrough: null,
+
+ /** queue control */
+ _timeout: null,
+ /** enqueuing delay */
+ _delay:null,
+ /** queue size */
+ _queueSize:-1,
+
+ /**
+ back reference to the xhr queue,
+ only set if the object really is queued
+ */
+ _xhrQueue: null,
+
+ /** pps an array of identifiers which should be part of the submit, the form is ignored */
+ _partialIdsArray : null,
+
+ /** xhr object, internal param */
+ _xhr: null,
+
+ /** response object which is exposed to the queue */
+ _response: null,
+
+ /** predefined method */
+ _ajaxType:"POST",
+
+ //CONSTANTS
+ ENCODED_URL:"javax.faces.encodedURL",
+ /*
+ * constants used internally
+ */
+ _CONTENT_TYPE:"Content-Type",
+ _HEAD_FACES_REQ:"Faces-Request",
+ _VAL_AJAX: "partial/ajax",
+ _XHR_CONST: myfaces._impl.xhrCore.engine.XhrConst,
+
+ // _exception: null,
+ // _requestParameters: null,
+ /**
+ * Constructor
+ * <p />
+ * note there is a load of common properties
+ * inherited by the base class which define the corner
+ * parameters and the general internal behavior
+ * like _onError etc...
+ * @param {Object} args an arguments map which an override any of the given protected
+ * instance variables, by a simple name value pair combination
+ */
+ constructor_: function(args) {
+
+ try {
+ this._callSuper("constructor_", args);
+ this._initDefaultFinalizableFields();
+
+ this._onException = this._Lang.hitch(this, this._stdErrorHandler);
+ this._onWarn = this._Lang.hitch(this, this._stdErrorHandler);
+
+ this._Lang.applyArgs(this, args);
+ var mfInternal = this._context._mfInternal;
+ mfInternal._onException = this._onException;
+ mfInternal._onWarning = this._onWarn;
+
+ /*namespace remapping for readability*/
+ //we fetch in the standard arguments
+ //and apply them to our protected attributes
+ //we do not gc the entry hence it is not defined on top
+ var xhrCore = myfaces._impl.xhrCore;
+ this._AJAXUTIL = xhrCore._AjaxUtils;
+
+ //we cannot eliminate it due to the direct reference to its request the response needs
+ //at least for now, in the long run we can and must
+ this._response = xhrCore._AjaxResponse;
+ } catch (e) {
+ //_onError
+ this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "constructor", e);
+ }
+ },
- this._ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(this._onException, this._onWarning);
- } catch (e) {
- //_onError
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "constructor", e);
- }
- },
-
- /**
- * Sends an Ajax request
- */
- send : function() {
- try {
- //we have to encode at send time, otherwise
- //we pick up old viewstates
- this._initRequestParams();
- this._startXHR();
- this._startTimeout();
- } catch (e) {
- //_onError//_onError
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "send", e);
- }
- },
-
-
- /**
- * gets the ViewState including all now passed in sideconstraints
- */
- _initRequestParams: function() {
- this._requestParameters = this.getViewState();
- for (var key in this._passThrough) {
- this._requestParameters.append(key, this._passThrough[key]);
- }
- },
-
- /**
- * starts the asynchronous xhr request
- */
- _startXHR: function() {
- this._preCreateXHR();
- this._xhr = myfaces._impl.core._Runtime.getXHRObject();
- this._postCreateXHR();
-
- var targetURL;
- if (typeof this._sourceForm.elements["javax.faces.encodedURL"] == 'undefined') {
- targetURL = this._sourceForm.action;
- } else {
- targetURL = this._sourceForm.elements["javax.faces.encodedURL"].value;
- }
-
- this._xhr.open(this._ajaxType, targetURL +
- ((this._ajaxType == "GET") ? "?" + this._requestParameters.makeFinal() : "")
- , true);
-
- var contentType = this._contentType;
- if (this._encoding) {
- contentType = contentType + "; charset:" + this._encoding;
- }
-
- this._xhr.setRequestHeader(this._CONTENT_TYPE, this._contentType);
- this._xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
-
- this._xhr.onreadystatechange = this._Lang.hitch(this, this.callback);
- var _Impl = this._getImpl();
- _Impl.sendEvent(this._xhr, this._context, _Impl.BEGIN);
-
- this._preSend();
-
- try {
- this._xhr.send((this._ajaxType != "GET") ? this._requestParameters.makeFinal() : null);
- } finally {
- this._postSend();
- }
- },
-
-
-
- /**
- * starts the timeout
- * which is able to terminate the xhr upfront early
- */
- _startTimeout: function() {
- if (this._timeout && this._onTimeout) {
- var _req = this._xhr;
- var _context = this._context;
- if (this._timeoutId) {
- window.clearTimeout(this._timeoutId);
- this._timeoutId = null;
- }
- this._timeoutId = window.setTimeout(
- //we unify the api, there must be always a request passed to the external function
- //and always a context, no matter what
- this._Lang.hitch(this,
- function() {
- //the hitch has to be done due to the setTimeout refocusing the scope of this
- //to window
- try {
- _req.onreadystatechange = function() {
- };
-
- //to avoid malformed whatever, we have
- //the timeout covered already on the _onTimeout function
- _req.abort();
- this._onTimeout(_req, _context);
- } catch (e) {
- alert(e);
- } finally {
- }
- })
- , this._timeout);
- }
- },
-
- /**
- * Callback method to process the Ajax response
- * triggered by RequestQueue
- */
- callback : function() {
-
- try {
- var _Impl = this._getImpl();
-
- if (this._xhr.readyState == this._READY_STATE_DONE) {
- if (this._timeoutId) {
- //normally the timeout should not cause anything anymore
- //but just to make sure
- window.clearTimeout(this._timeoutId);
- this._timeoutId = null;
- }
- this._onDone(this);
- if (this._xhr.status >= this._STATUS_OK_MINOR && this._xhr.status < this._STATUS_OK_MAJOR) {
- this._onSuccess();
- } else {
- this._onError();
+ /**
+ * Sends an Ajax request
+ */
+ send : function() {
+
+ var _Lang = this._Lang;
+
+ try {
+
+ var scopeThis = _Lang.hitch(this, function(functionName) {
+ return _Lang.hitch(this, this[functionName]);
+ });
+ this._xhr = _Lang.mixMaps(this._getTransport(), {
+ onprogress: scopeThis("onprogress"),
+ ontimeout: scopeThis("ontimeout"),
+ onloadend: scopeThis("ondone"),
+ onload: scopeThis("onsuccess"),
+ onerror: scopeThis("onerror")
+
+ }, true);
+ var xhr = this._xhr;
+
+ var targetURL = (typeof this._sourceForm.elements[this.ENCODED_URL] == 'undefined') ?
+ this._sourceForm.action :
+ this._sourceForm.elements[this.ENCODED_URL].value;
+
+ var formData = this.getFormData();
+ for (var key in this._passThrough) {
+ formData.append(key, this._passThrough[key]);
+ }
+
+ xhr.open(this._ajaxType, targetURL +
+ ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "")
+ , true);
+ xhr.timeout = this._timeout || 0;
+ var contentType = this._contentType;
+ if (this._encoding) {
+ contentType = contentType + "; charset:" + this._encoding;
+ }
+
+ xhr.setRequestHeader(this._CONTENT_TYPE, this._contentType);
+ xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
+
+ this._sendEvent("BEGIN");
+ //Check if it is a custom form data object
+ //if yes we use makefinal for the final handling
+ if (formData && formData.makeFinal) {
+ formData = formData.makeFinal()
+ }
+ xhr.send((this._ajaxType != "GET") ? formData : null);
+
+ } catch (e) {
+ //_onError//_onError
+ this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "send", e);
}
- }
- } catch (e) {
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "callback", e);
- } finally {
- //final cleanup to terminate everything
- this._Lang.clearExceptionProcessed();
-
- //this._context.source;
- if (this._xhr.readyState == this._READY_STATE_DONE) {
- this._callSuper("_finalize");
- }
+ },
+
+
+ ondone: function() {
+ this._requestDone();
+ },
+
+
+ onsuccess: function(evt) {
+
+ var context = this._context;
+ var xhr = this._xhr;
+ try {
+ this._sendEvent("COMPLETE");
+ //now we have to reroute into our official api
+ //because users might want to decorate it, we will split it apart afterwards
+ context._mfInternal = context._mfInternal || {};
+ context._mfInternal._mfRequest = this;
+
+ jsf.ajax.response((xhr.getXHRObject) ? xhr.getXHRObject() : xhr, context);
+
+ this._sendEvent("SUCCESS");
+ } catch (e) {
+ this._onException(xhr, context, "myfaces._impl.xhrCore._AjaxRequest", "callback", e);
+ }
+ },
- }
- },
+ onerror: function(evt) {
+ var context = this._context;
+ var xhr = this._xhr;
+ var _Lang = this._Lang;
+
+ var errorText = "";
+ this._sendEvent("COMPLETE");
+ try {
+ var UNKNOWN = _Lang.getMessage("UNKNOWN");
+ errorText = _Lang.getMessage("ERR_REQU_FAILED", null,
+ (xhr.status || UNKNOWN),
+ (xhr.statusText || UNKNOWN));
+
+ } catch (e) {
+ errorText = _Lang.getMessage("ERR_REQ_FAILED_UNKNOWN", null);
+ } finally {
+ var _Impl = this._getImpl();
+ _Impl.sendError(xhr, context, _Impl.HTTPERROR,
+ _Impl.HTTPERROR, errorText);
+ }
+ //_onError
+ },
+ onprogress: function(evt) {
+ //do nothing for now
+ },
+
+ ontimeout: function(evt) {
+
+ try {
+ //we issue an event not an error here before killing the xhr process
+ this._sendEvent("TIMEOUT_EVENT");
+ //timeout done we process the next in the queue
+ } finally {
+ this._requestDone();
+ }
+ },
+ _formDataToURI: function(formData) {
+ if (formData && formData.makeFinal) {
+ formData = formData.makeFinal()
+ }
+ return formData;
+ },
+ _getTransport: function() {
+ var _Rt = myfaces._impl.core._Runtime;
+ //same interface between 1 and 2, in the worst case
+ //so we can make a drop in replacement, on level2
+ //we have one layer less hence we can work directly
+ //on the xhr object, on level2 we have our engine
+ //emulation layer which thunks back into level1
+ //for all calls
+
+ var xhr = myfaces._impl.core._Runtime.getXHRObject();
+ //the current xhr level2 timeout w3c spec is not implemented by the browsers yet
+ //we have to do a fallback to our custom routines
+ if (('undefined' == typeof this._timeout || null == this._timeout) && _Rt.getXHRLvl() >= 2) {
+ //no timeout we can skip the emulation layer
+ return xhr;
+ }
- /*
- * various lifecycle callbacks which can be used by differing AjaxRequest impls
- * (namely level 1.5 (Mozilla XHR) and level 2 (html5 xhr) to run special initialisation code
- **/
- _preCreateXHR : function() {
- //called after the xhr object has been created
- },
+ return new myfaces._impl.xhrCore.engine.Xhr1({xhrObject: xhr});
+ },
- _postCreateXHR : function() {
- //called after the xhr object has been created
- },
- _preSend : function() {
- //called before the xhr object is sent
- },
- _postSend : function() {
- //called after the xhr object is sent for cleanup purposes
- }
-});
+
+ //----------------- backported from the base request --------------------------------
+ //non abstract ones
+ /**
+ * Spec. 13.3.1
+ * Collect and encode input elements.
+ * Additionally the hidden element javax.faces.ViewState
+ *
+ *
+ * @return an element of formDataWrapper
+ * which keeps the final Send Representation of the
+ */
+ getFormData : function() {
+
+ var ret = this._Lang.createFormDataDecorator(new Array());
+
+ this._AJAXUTIL.encodeSubmittableFields(ret, this._xhr, this._context, this._source,
+ this._sourceForm, this._partialIdsArray);
+
+ return ret;
+ },
+
+ _getImpl: function() {
+
+ this._Impl = this._Impl || myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+ return this._Impl;
+ },
+
+ /**
+ * Client error handlers which also in the long run route into our error queue
+ * but also are able to deliver more meaningful messages
+ * note, in case of an error all subsequent xhr requests are dropped
+ * to get a clean state on things
+ *
+ * @param request the xhr request object
+ * @param context the context holding all values for further processing
+ * @param sourceClass (String) the issuing class for a more meaningful message
+ * @param func the issuing function
+ * @param exception the embedded exception
+ */
+ _stdErrorHandler: function(request, context, sourceClass, func, exception) {
+
+ var xhrQueue = this._xhrQueue;
+ try {
+ var _Impl = this._getImpl();
+ _Impl.stdErrorHandler(request, context, sourceClass, func, exception);
+ } finally {
+ if (xhrQueue) {
+ xhrQueue.cleanup();
+ }
+ }
+ },
+
+ _sendEvent: function(evtType) {
+
+ var _Impl = this._getImpl();
+ _Impl.sendEvent(this._xhr, this._context, _Impl[evtType]);
+ },
+
+ _requestDone: function() {
+
+ if (this._xhrQueue) {
+ this._xhrQueue.processQueue();
+ }
+ //ie6 helper cleanup
+ delete this._context.source;
+ this._finalize();
+ },
+
+ //cleanup
+ _finalize: function() {
+
+ //final cleanup to terminate everything
+ this._Lang.clearExceptionProcessed();
+
+ //_t._context.source;
+ if (this._xhr.readyState == this._XHR_CONST.READY_STATE_DONE) {
+ this._callSuper("_finalize");
+ }
+ }
+ });
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestLevel2.js Wed Sep 14 12:56:05 2011
@@ -13,57 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/**
- * an implementation of an xhr level2 object
- * doing all needed operations (aka FormElement, input type submit handling,
- * progress notifications)
- *
- * NOTE this is alpha code since the browsers emit currently insufficient
- * multipart data, this will be enabled as soon as it is possible
- *
- * Author: Werner Punz (latest modification by $Author: werpu $)
- * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
+ * this method is used only for pure multipart form parts
+ * otherwise the normal method is used
+ * IT is a specialized request which uses the form data
+ * element for the handling of forms
*/
-
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, {
+ _sourceForm: null,
+
constructor_: function(arguments) {
- this._callSuper("constructor", arguments);
- //this._contentType = "multipart/form-data; boundary=---------------------------168072824752491622650073 ";
- },
+ this._callSuper("constructor_", arguments);
+ //TODO xhr level2 can deal with real props
- /**
- * internal callback from AjaxRequest._startXHR
- * at this stage the xhr object has been initialized last
- * post finish works like additional listeners can be registered
- */
- _preSend: function() {
- this._callSuper("_preSend");
},
- /**
- * xhr level2 optimized getViewState element
- */
- getViewState: function() {
- var _Lang = myfaces._impl._util._Lang;
- var _ret;
+ getFormData: function() {
+ var ret;
if (!this._partialIdsArray || this._partialIdsArray.length == 0) {
- //Standard case we have only the normal form issued
- //var getFormDataPresent = this._sourceForm.getFormData;
- _ret = _Lang.createFormDataDecorator(new FormData());
- //_ret = _Lang.createFormDataDecorator((getFormDataPresent) ? this._sourceForm.getFormData() : new FormData());
- if (true) {
- this._ajaxUtil.encodeSubmittableFields(_ret, this._xhr, this._context, this._source,
- this._sourceForm, this._partialIdsArray);
- }
- this._ajaxUtil.appendIssuingItem(this._source, _ret);
+ ret = new FormData(this._sourceForm);
} else {
- _ret = _Lang.createFormDataDecorator(new FormData());
- this._ajaxUtil.encodeSubmittableFields(_ret, this._xhr, this._context, this._source,
+ //for speed reasons we only need encodesubmittablefields
+ //in the pps case
+ ret = new FormData(this._sourceForm);
+ this._AJAXUTIL.encodeSubmittableFields(ret, this._xhr, this._context, this._source,
this._sourceForm, this._partialIdsArray);
}
- return _ret;
+ return ret;
+ },
+
+ _formDataToURI: function() {
+ //i assume in xhr level2 form data takes care of the http get parametrisation
+ return "";
+ },
+
+ _getTransport: function() {
+ return new XMLHttpRequest();
}
-});
+});
\ No newline at end of file
Modified: myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js?rev=1170583&r1=1170582&r2=1170583&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js (original)
+++ myfaces/core/branches/2.0.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequestQueue.js Wed Sep 14 12:56:05 2011
@@ -14,7 +14,9 @@
* limitations under the License.
*/
/** @namespace myfaces._impl.xhrCore._AjaxRequestQueue */
-myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequestQueue", myfaces._impl._util._Queue, {
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequestQueue", myfaces._impl._util._Queue,
+ /** @lends myfaces._impl.xhrCore._AjaxRequestQueue.prototype */
+ {
/**
* a pointer towards the currently processed