Author: pedro
Date: Tue Apr 26 15:26:46 2011
New Revision: 1096784

URL: http://svn.apache.org/viewvc?rev=1096784&view=rev
Log:
Fixing the JavaScript evaluation sequence for 1.5 by executing post handlers in 
another thread after set the new header.
Issue: WICKET-3473

Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1096784&r1=1096783&r2=1096784&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
(original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
Tue Apr 26 15:26:46 2011
@@ -169,12 +169,6 @@ Wicket.FunctionsExecuter.prototype = {
        }
 }
 
-/*
-  WICKET-3473 Helper to proceed to next step, execution of notify needs to be 
delayed until the head contributions are loaded
-*/
-Wicket.functionExecuterSeq = 0;
-Wicket.functionExecuterCallbacks = {};
-
 Wicket.replaceOuterHtmlIE = function(element, text) {                          
                
 
        // replaces all <iframe references with 
<__WICKET_JS_REMOVE_X9F4A__iframe text
@@ -1643,13 +1637,12 @@ Wicket.Head.Contributor.prototype = {
                                // load the external javascript using 
Wicket.Ajax.Request
                                
                                // callback when script is loaded
-                var callBackIdentifier = 'script' + 
(Wicket.functionExecuterSeq++);
                 var onLoad = function(content) {
-                    Wicket.functionExecuterCallbacks[callBackIdentifier] = 
function() {
+                                       Wicket.Head.addJavascript(content, 
null, src);
+                                       setTimeout(function() {
                         Wicket.Ajax.invokePostCallHandlers();
                         notify();
-                    }
-                                       Wicket.Head.addJavascript(content+"; 
Wicket.functionExecuterCallbacks['"+callBackIdentifier+"'](); delete 
Wicket.functionExecuterCallbacks['"+callBackIdentifier+"']; ", null, src);
+                    }, 0);
                                }
                                // we need to schedule the request as timeout
                                // calling xml http request from another 
request call stack doesn't work
@@ -1789,6 +1782,7 @@ Wicket.Head.stripJSessionId = function(u
 // also a src value. Therefore we put the url to the src_ (notice the 
underscore)  attribute.
 // Wicket.Head.containsElement is aware of that and takes also the underscored 
attributes into account.
 Wicket.Head.addJavascript = function(content, id, fakeSrc) {
+       content = 'try{'+content+'}catch(e){WicketAjaxDebug.logError(e);}';
        var script = Wicket.Head.createElement("script");
        if (id) {
                script.id = id;


Reply via email to