Author: pyaschenko
Date: 2007-10-29 10:18:48 -0400 (Mon, 29 Oct 2007)
New Revision: 3598
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
onComplete is invoking when all scripts are evaluated in updatePagePart
RF-932 fixed
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-10-29 14:14:33 UTC
(rev 3597)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-10-29 14:18:48 UTC
(rev 3598)
@@ -73,6 +73,7 @@
requestStatus = 599;
requestStatusText = "Network error";
}
+ var onReadyFlag = true;
if(requestStatus == 200){
try {
LOG.debug("Response with content-type: "+
_this.getResponseHeader('Content-Type'));
@@ -88,8 +89,10 @@
}
}
if(_this.onready){
+ onReadyFlag = false;
_this.onready(_this);
- }
+ }
+
} else {
_this._errorMessage = "Reqest error, status : "+requestStatus
+" " + requestStatusText ;
LOG.error(_this._errorMessage);
@@ -97,10 +100,11 @@
_this._onerror(_this,requestStatus,_this._errorMessage);
}
}
- if(_this.onfinish){
+ if (onReadyFlag && _this.onfinish)
+ {
_this.onfinish(_this);
}
- _this = undefined;
+ _this = undefined;
}
}; //this._onReady;
try{
@@ -284,10 +288,11 @@
return data;
},
- evalScripts : function(node){
+ evalScripts : function(node, isLast){
var newscripts = this.getElementsByTagName("script",node);
LOG.debug("Scripts in updated part count : " + newscripts.length);
if( newscripts.length > 0 ){
+ var _this = this;
window.setTimeout(function() {
for (var i = 0; i < newscripts.length; i++){
var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla
disable innerHTML in XML page ..."";
@@ -303,14 +308,39 @@
}
}
newscripts = null;
+ if (isLast)
+ {
+ if(_this.onfinish){
+ _this.onfinish(_this);
+ _this=undefined;
+ }
+ }
},50);
+ } else
+ {
+ if (isLast)
+ {
+ if(this.onfinish){
+ this.onfinish(this);
+ }
+ }
}
+
},
+
+ beforeUpdatePagePart: function (id)
+ {
+ var oldnode = window.document.getElementById(id);
+ if ( oldnode ) {
+
+ }
+ },
+
/**
* Update DOM element with given ID by element with same ID in parsed responseXML
*/
- updatePagePart : function(id){
+ updatePagePart : function(id, isLast){
var newnode = this.getElementById(id);
if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in
response");return;}
var oldnode = window.document.getElementById(id);
@@ -336,13 +366,20 @@
// re-execute all script fragments in imported subtree...
// TODO - opera 8 run scripts at replace content stage.
if(!A4J.AJAX._scriptEvaluated){
- this.evalScripts(newnode);
+ this.evalScripts(newnode, isLast);
}
LOG.debug("Update part of page for Id: "+id + "
successful");
} else {
LOG.warn("Node for replace by response with id "+id+" not found in
document");
}
+ if (A4J.AJAX._scriptEvaluated && isLast)
+ {
+ if(this.onfinish){
+ this.onfinish(this);
+ }
+ }
+
},
appendNewHeadElements : function(){
@@ -713,7 +750,7 @@
req.appendNewHeadElements();
for ( var k =0; k < options.affected.length ; k++ ) {
LOG.debug("Update page part from call parameter for ID " +
options.affected[k]);
- req.updatePagePart(options.affected[k]);
+ req.updatePagePart(options.affected[k], k==childs.length-1);
};
// if resopnce contains element with ID "ajax:update" get id's from
// child text element . like :
@@ -730,7 +767,7 @@
for ( var k=0 ; k < childs.length ; k++ ) {
var id = childs[k];
LOG.debug("Attempt to update part of page for Id: "+id);
- if ( id ) {req.updatePagePart(id);};
+ if ( id ) {req.updatePagePart(id, k==childs.length-1);};
};
} else {
// if none of above - error ?
Show replies by date