This content has been marked as final.
Show 1 reply
-
1. Re: Scope change in oncompete handler for a4j:commandButton?
loopingrage Dec 6, 2007 2:08 PM (in response to loopingrage)Well, I found my answer. It turns out that 3.1 did indeed change the way it executes oncomplete handlers. It is doing window.eval instead of executing the reference to options.oncomplete passed in to A4J.AJAX.Submit.
Can someone on the ajax4jsf team tell me why the change was made and if there's a way to suppress "org.ajax4jsf.oncomplete" from the request?
Old way:A4J.AJAX.finishRequest = function (req) { var options = req.options; A4J.AJAX.status(req.containerId, options.status, false); if (options.oncomplete) { LOG.debug("Call request oncomplete function after processing updates"); window.setTimeout(function () { options.oncomplete(req, req.domEvt, req.getJSON("_ajax:data")); }, 50); } if (options.eventsQueue) { var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue]; if (eventsQueue) { A4J.AJAX._eventsQueues[options.eventsQueue] = false; if (eventsQueue.wait) { LOG.debug("Queue not empty, execute next request in queue " + options.eventsQueue); A4J.AJAX.SubmiteventsQueue(eventsQueue); } } } };
New way:A4J.AJAX.finishRequest = function (request) { var options = request.options; if ((typeof Event != "undefined") && (typeof Event.unloadElementsCache == "function")) { Event.unloadElementsCache(); } var oncomplete = request.getElementById("org.ajax4jsf.oncomplete"); if (oncomplete) { LOG.debug("Call request oncomplete function after processing updates"); window.setTimeout(function () { var event = request.domEvt; var data = request.getJSON("_ajax:data"); try { var newscript = Sarissa.getText(oncomplete, true); window.eval(newscript); } catch (e) { LOG.error("Error evaluate oncomplete function " + e.Message); } A4J.AJAX.status(request.containerId, options.status, false); }, 10); } else { if (options.oncomplete) { LOG.debug("Call component oncomplete function after processing updates"); window.setTimeout(function () { options.oncomplete(request, request.domEvt, request.getJSON("_ajax:data")); A4J.AJAX.status(request.containerId, options.status, false); }, 10); } else { A4J.AJAX.status(request.containerId, options.status, false); } }