Author: knopp
Date: Sat Jul 28 01:54:07 2007
New Revision: 560523
URL: http://svn.apache.org/viewvc?view=rev&rev=560523
Log:
Better DOM state corruption detection
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/res/tree.js
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/res/tree.js
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/res/tree.js?view=diff&rev=560523&r1=560522&r2=560523
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/res/tree.js
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/res/tree.js
Sat Jul 28 01:54:07 2007
@@ -20,19 +20,36 @@
Wicket.Tree = { };
+Wicket.Tree.askForReload = function() {
+ if (confirm("There was a problem updating the tree. It might be caused
be the old page being cached by the browser. \n"+
+ "It is recommended to reload the page. Do you want to
reload it?")) {
+ window.location.reload();
+ }
+}
+
Wicket.Tree.removeNodes = function(prefix, nodeList) {
+ var problem = false;
for (var i = 0; i < nodeList.length; i++) {
var e = document.getElementById(prefix + nodeList[i]);
if (e != null) {
e.parentNode.removeChild(e);
} else {
// while developing alert a warning
- alert("Can't find node with id " + prefix + nodeList[i]
+ ". This shouldn't happen - possible bug in tree?");
+ problem = true;
+ Wicket.Log.error("Can't find node with id " + prefix +
nodeList[i] + ". This shouldn't happen - possible bug in tree?");
}
}
+ if (problem == true) {
+ Wicket.Tree.askForReload();
+ }
}
Wicket.Tree.createElement = function(elementId, afterId) {
+ var existing = Wicket.$(elementId);
+ if (typeof(existing) != "undefined" && exiting != null) {
+ Wicket.Tree.askForReload();
+ }
+
var after = document.getElementById(afterId);
var newNode = document.createElement("script");
newNode.setAttribute("id", elementId);