Author: dmorozov
Date: 2008-11-17 11:13:42 -0500 (Mon, 17 Nov 2008)
New Revision: 11191
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
https://jira.jboss.org/jira/browse/RF-4899
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2008-11-17
13:37:32 UTC (rev 11190)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2008-11-17
16:13:42 UTC (rev 11191)
@@ -297,18 +297,12 @@
}
String oncomplete = getAjaxOncomplete(uiComponent);
if (null != oncomplete) {
- JSFunctionDefinition function = new JSFunctionDefinition("request",
"event", "data");
- function.addToBody(oncomplete);
-
- options.put(ONCOMPLETE_ATTR_NAME, function);
+ options.put(ONCOMPLETE_ATTR_NAME, buildAjaxOncomplete(oncomplete));
}
String beforeupdate = getAjaxOnBeforeDomUpdate(uiComponent);
if (null != beforeupdate) {
- JSFunctionDefinition function = new JSFunctionDefinition("request",
"event", "data");
- function.addToBody(beforeupdate);
-
- options.put(ONBEFOREDOMUPDATE_ATTR_NAME, function);
+ options.put(ONBEFOREDOMUPDATE_ATTR_NAME, buildAjaxOnBeforeDomUpdate(beforeupdate));
}
@@ -572,6 +566,20 @@
return statusId;
}
+ public static JSFunctionDefinition buildAjaxOncomplete(String body) {
+ JSFunctionDefinition function = new JSFunctionDefinition("request",
"event", "data");
+ function.addToBody(body);
+
+ return function;
+ }
+
+ public static JSFunctionDefinition buildAjaxOnBeforeDomUpdate(String body) {
+ JSFunctionDefinition function = new JSFunctionDefinition("request",
"event", "data");
+ function.addToBody(body);
+
+ return function;
+ }
+
/**
* Get function name for call on completed ajax request.
*
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-11-17 13:37:32 UTC
(rev 11190)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-11-17 16:13:42 UTC
(rev 11191)
@@ -865,9 +865,19 @@
if(req.getParserStatus() == Sarissa.PARSED_OK){
// perform beforeupdate if exists
- if(options.onbeforedomupdate){
- LOG.debug( "Call request onbeforedomupdate function before replacing
elemements" );
- options.onbeforedomupdate(req, req.domEvt, req.getJSON('_ajax:data'));
+ if(options.onbeforedomupdate || options.queueonbeforedomupdate){
+ var event = req.domEvt;
+ var data = req.getJSON('_ajax:data');
+
+ LOG.debug( "Call local onbeforedomupdate function before replacing
elemements" );
+
+ if (options.onbeforedomupdate) {
+ options.onbeforedomupdate(req, event, data);
+ }
+
+ if (options.queueonbeforedomupdate) {
+ options.queueonbeforedomupdate(req, event, data);
+ }
}
var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
@@ -1071,24 +1081,42 @@
window.setTimeout(function(){
var event = request.domEvt;
var data = request.getJSON('_ajax:data');
- try {
+
+ try {
+ var target = null;
+ if (event) {
+ target = event.target ? event.target : event.srcElement;
+ }
+
var newscript = Sarissa.getText(oncomp,true);
var oncomplete = new
Function("request","event","data",newscript);
- var target = null;
- if (event) {
- target = event.target ? event.target : event.srcElement;
- };
oncomplete.call(target,request,event,data);
- } catch(e){
- LOG.error('Error evaluate oncomplete function '+e.Message);
- }
-// mark status object ( if any ) for complete request ;
+
+ if (options.queueoncomplete) {
+ options.queueoncomplete.call(target, request, event, data);
+ }
+
+ } catch (e) {
+ LOG.error('Error evaluate oncomplete function '+e.Message);
+ }
+
+ // mark status object ( if any ) for complete request ;
A4J.AJAX.status(request.containerId,options.status,false);},
0);
- } else if(options.oncomplete){
- LOG.debug( "Call component oncomplete function after processing updates"
);
+ } else if (options.oncomplete || options.queueoncomplete){
+ LOG.debug( "Call local oncomplete function after processing updates" );
window.setTimeout(function(){
-
options.oncomplete(request,request.domEvt,request.getJSON('_ajax:data'));
+ var event = request.domEvt;
+ var data = request.getJSON('_ajax:data');
+
+ if (options.oncomplete) {
+ options.oncomplete(request, event, data);
+ }
+
+ if (options.queueoncomplete) {
+ options.queueoncomplete(request, event, data);
+ }
+
// mark status object ( if any ) for complete request ;
A4J.AJAX.status(request.containerId,options.status,false);},
0);
@@ -1098,7 +1126,7 @@
A4J.AJAX.status(request.containerId,options.status,false);
}
- if (request.queue) {
+ if (request.shouldNotifyQueue && request.queue) {
request.queue.pop();
}
};
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-17 13:37:32 UTC (rev
11190)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-17 16:13:42 UTC (rev
11191)
@@ -166,7 +166,7 @@
}
if (this.pipeline.isFull()) {
- var behavior = data.queue.getSizeExceededBehavior();
+ var behavior = data.getSizeExceededBehavior();
if (behavior == DROP_NEW ||
(behavior == DROP_NEXT && !this.pipeline.hasNextItem())) {
@@ -202,8 +202,6 @@
this.gate = new Gate();
this.pipeline = new Pipeline(this.queueOptions.size, this.gate);
this.gate.pipeline = this.pipeline;
-
- this.queue = new Array();
};
A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME = "org.richfaces.queue.global";
@@ -246,7 +244,6 @@
formQueueName = qualifyName(queueName, formId);
viewQueueName = qualifyName(queueName, namespace);
- //TODO nick - support settings for default queue scope
implicitQueueName = viewQueueName;
} else {
formQueueName = formId;
@@ -383,20 +380,21 @@
};
extend(EventQueueData.prototype, {
- submitWithCallback: function() {
+ submitWithoutCallback: function() {
this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
-
var request = A4J.AJAX.SubmitQuery(this.query, this.options)
request.queue = this.queue;
+
+ return request;
+ },
+
+ submitWithCallback: function() {
+ var request = this.submitWithoutCallback();
+ request.shouldNotifyQueue = true;
return request;
},
- submitWithoutCallback: function() {
- this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
- return A4J.AJAX.SubmitQuery(this.query, this.options)
- },
-
getRequestId: function() {
return this.options.requestId;
},
@@ -405,8 +403,20 @@
return this.options.requestDelay;
},
+ getSizeExceededBehavior: function() {
+ return this.queue.getSizeExceededBehavior();
+ },
+
setEventsCounter: function(count) {
this.eventsCount = count;
+ },
+
+ setRequest: function() {
+ //TODO nick
+ },
+
+ shouldSubmitWithoutCallback: function() {
+ //TODO nick
}
});