Author: knopp
Date: Wed Sep 26 04:16:51 2007
New Revision: 579593
URL: http://svn.apache.org/viewvc?rev=579593&view=rev
Log:
Allow arbitrary delaying of Ajax pipeline using prepend/append javascript
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=579593&r1=579592&r2=579593&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
Wed Sep 26 04:16:51 2007
@@ -1116,15 +1116,34 @@
if (encoding != null) {
text = Wicket.decode(encoding, text);
}
- try {
- // do the evaluation
- eval(text);
- } catch (exception) {
- Wicket.Log.error("Exception evaluating javascript: " +
exception);
- }
- // continue to next step
- notify();
- });
+
+ // test if the javascript is in form of identifier|code
+ // if it is, we allow for letting the javascript decide
when the rest of processing will continue
+ // by invoking identifier();
+ var res = text.match("([a-z|A-Z_][a-z|A-Z|0-9_]*)\\|(.*)");
+
+ if (res != null) {
+ text = "var f = function(" + res[1] + ") {" + res[2]
+"};";
+ try {
+ // do the evaluation
+ eval(text);
+ f(notify);
+ } catch (exception) {
+ Wicket.Log.error("Exception evaluating
javascript: " + exception);
+ }
+
+ } else {
+ // just evaluate the javascript
+ try {
+ // do the evaluation
+ eval(text);
+ } catch (exception) {
+ Wicket.Log.error("Exception evaluating
javascript: " + exception);
+ }
+ // continue to next step
+ notify();
+ }
+ });
},
// Adds a closure that processes a header contribution