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 2012/12/12 13:26:04 UTC
svn commit: r1420640 - in
/myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore:
_AjaxRequest.js _Transports.js engine/IFrame.js
Author: werpu
Date: Wed Dec 12 12:26:01 2012
New Revision: 1420640
URL: http://svn.apache.org/viewvc?rev=1420640&view=rev
Log:
updating the window id handling to the latest spec changes
fixing a concurrency bug in the iframe transport so that the values are reset always at the correct stage
Modified:
myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js
Modified: myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=1420640&r1=1420639&r2=1420640&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Wed Dec 12 12:26:01 2012
@@ -173,25 +173,38 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
e = (e._mfInternal) ? e : this._Lang.makeException(new Error(), "sendError", "sendError", this._nameSpace, "send", e.message);
this._stdErrorHandler(this._xhr, this._context, e);
} finally {
- this._restoreClientWindowId();
+ //no finally possible since the iframe uses real asynchronousity
}
},
_applyClientWindowId:function () {
-
+ var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
+ //pass through if exists already set by _Impl
if ('undefined' != typeof this._context._mfInternal._clientWindow) {
- var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
this._context._mfInternal._clientWindowOld = clientWindow.value;
clientWindow.value = this._context._mfInternal._clientWindow;
+ } else {
+ if(clientWindow) {
+ this._context._mfInternal._clientWindowDisabled = !! clientWindow.disabled;
+ clientWindow.disabled = true;
+ }
}
},
_restoreClientWindowId:function () {
//we have to reset the client window back to its original state
+
+ var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
+ if(!clientWindow) {
+ return;
+ }
if ('undefined' != typeof this._context._mfInternal._clientWindowOld) {
- var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow");
clientWindow.value = this._context._mfInternal._clientWindow;
}
+ if('undefined' != typeof this._context._mfInternal._clientWindowDisabled) {
+ //we reset it to the old value
+ clientWindow.disabled = this._context._mfInternal._clientWindowDisabled;
+ }
},
/**
@@ -210,7 +223,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
},
onsuccess:function (/*evt*/) {
-
+ this._restoreClientWindowId();
var context = this._context;
var xhr = this._xhr;
try {
@@ -232,6 +245,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
},
onerror:function (/*evt*/) {
+ this._restoreClientWindowId();
//TODO improve the error code detection here regarding server errors etc...
//and push it into our general error handling subframework
var context = this._context;
@@ -271,6 +285,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
ontimeout:function (/*evt*/) {
try {
+ this._restoreClientWindowId();
//we issue an event not an error here before killing the xhr process
this._sendEvent("TIMEOUT_EVENT");
//timeout done we process the next in the queue
Modified: myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js?rev=1420640&r1=1420639&r2=1420640&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js (original)
+++ myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js Wed Dec 12 12:26:01 2012
@@ -169,11 +169,11 @@ _MF_SINGLTN(_PFX_XHR + "_Transports", _M
* @param context the context which is passed down
*/
_getMultipartReqClass: function(context) {
- if (this._RT.getXHRLvl() >= 2) {
+ if (this._RT.getXHRLvl() >= 2) {
return myfaces._impl.xhrCore._MultipartAjaxRequestLevel2;
- } else {
+ } else {
return myfaces._impl.xhrCore._IFrameRequest;
- }
+ }
},
Modified: myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js?rev=1420640&r1=1420639&r2=1420640&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js (original)
+++ myfaces/core/branches/2.2.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/engine/IFrame.js Wed Dec 12 12:26:01 2012
@@ -24,18 +24,17 @@
* wrapper for an iframe transport object with all its differences
* it emulates the xhr level2 api
*/
-_MF_CLS(_PFX_XHR+"engine.IFrame", myfaces._impl.xhrCore.engine.BaseRequest,
+_MF_CLS(_PFX_XHR + "engine.IFrame", myfaces._impl.xhrCore.engine.BaseRequest,
/** @lends myfaces._impl.xhrCore.engine.IFrame.prototype */
{
-
+ _finalized: false,
/*the target frame responsible for the communication*/
_frame: null,
//_requestHeader: null,
_aborted: false,
-
CLS_NAME: "myfaces._impl.xhrCore._IFrameRequest",
_FRAME_ID: "_mf_comm_frm",
@@ -45,7 +44,7 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
*
* @param arguments
*/
- constructor_: function(arguments) {
+ constructor_: function (arguments) {
//we fetch in the standard arguments
this._callSuper("constructor", arguments);
@@ -57,13 +56,14 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
this._Lang.applyArgs(this, arguments);
this.readyState = this._XHRConst.READY_STATE_UNSENT;
+ this._startTimeout();
},
- setRequestHeader: function(key, value) {
+ setRequestHeader: function (key, value) {
//this._requestHeader[key] = value;
},
- open: function(method, url, async) {
+ open: function (method, url, async) {
this.readyState = this._XHRConst.READY_STATE_OPENED;
@@ -94,7 +94,7 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
this.onprogress(myevt);
},
- send: function(formData) {
+ send: function (formData) {
var myevt = {};
this._addProgressAttributes(myevt, 20, 100);
@@ -102,11 +102,10 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
this.onprogress(myevt);
var formDataForm = formData.form,
- oldTarget = formDataForm.target,
- oldMethod = formDataForm.method,
- oldAction = formDataForm.action;
+ oldTarget = formDataForm.target,
+ oldMethod = formDataForm.method,
+ oldAction = formDataForm.action;
-
try {
//_t._initAjaxParams();
//for (var key in this._requestHeader) {
@@ -127,17 +126,19 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
formDataForm.method = oldMethod;
formData._finalize();
+ //alert("finalizing");
+ this._finalized = true;
}
},
/*we can implement it, but it will work only on browsers
* which have asynchronous iframe loading*/
- abort: function() {
+ abort: function () {
this._aborted = true;
this.onabort({});
},
- _addProgressAttributes: function(evt, percent, total) {
+ _addProgressAttributes: function (evt, percent, total) {
//http://www.w3.org/TR/progress-events/#progressevent
evt.lengthComputable = true;
evt.loaded = percent;
@@ -145,10 +146,22 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
},
- _callback: function() {
-
- //aborted no further processing
+ _callback: function () {
+ //------------------------------------
+ // we are asynchronous which means we
+ // have to check wether our code
+ // is finalized or not
+ //------------------------------------
if (this._aborted) return;
+ if (this._timeoutTimer) {
+ clearTimeout(this._timeoutTimer);
+ }
+ if (!this._finalized) {
+ setTimeout(this._Lang.hitch(this, this._callback), 10);
+ return;
+ }
+ //aborted no further processing
+
try {
var myevt = {};
@@ -182,21 +195,21 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
/**
* returns the frame text in a browser independend manner
*/
- _getFrameDocument: function() {
+ _getFrameDocument: function () {
//we cover various browsers here, because almost all browsers keep the document in a different
//position
return this._frame.contentWindow.document || this._frame.contentDocument || this._frame.document;
},
- _getFrameText: function() {
+ _getFrameText: function () {
var framedoc = this._getFrameDocument();
//also ie keeps the body in framedoc.body the rest in documentElement
var body = framedoc.body || framedoc.documentElement;
return body.innerHTML;
},
- _clearFrame: function() {
+ _clearFrame: function () {
var framedoc = this._getFrameDocument();
var body = framedoc.documentElement || framedoc.body;
@@ -213,14 +226,14 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
/**
* returns the processed xml from the frame
*/
- _getFrameXml: function() {
+ _getFrameXml: function () {
var framedoc = this._getFrameDocument();
//same situation here, the xml is hosted either in xmlDocument or
//is located directly under the frame document
return framedoc.XMLDocument || framedoc;
},
- _createTransportFrame: function() {
+ _createTransportFrame: function () {
var _FRM_ID = this._FRAME_ID;
var frame = document.getElementById(_FRM_ID);
@@ -268,10 +281,10 @@ _MF_CLS(_PFX_XHR+"engine.IFrame", myface
return document.getElementById(_FRM_ID);
},
- _startTimeout: function() {
+ _startTimeout: function () {
if (this.timeout == 0) return;
- this._timeoutTimer = setTimeout(this._Lang.hitch(this, function() {
+ this._timeoutTimer = setTimeout(this._Lang.hitch(this, function () {
if (this._xhrObject.readyState != this._XHRConst.READY_STATE_DONE) {
this._aborted = true;