Author: jcompagner
Date: Wed May 7 15:26:45 2008
New Revision: 654306
URL: http://svn.apache.org/viewvc?rev=654306&view=rev
Log:
WICKET-1366 java.lang.IllegalStateException: No Page found for component" when
collapsing nodes in a LinkTree (from 1.4 matej cant do these things him self)
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?rev=654306&r1=654305&r2=654306&view=diff
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
(original)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
Wed May 7 15:26:45 2008
@@ -20,11 +20,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Map.Entry;
import org.apache.wicket.Application;
@@ -481,10 +483,48 @@
}
/**
+ * Components can implement this interface to get a notification when
AjaxRequestTarget begins
+ * to respond. This can be used to postpone adding components to
AjaxRequestTarget until the
+ * response begins.
+ *
+ * @author Matej Knopp
+ */
+ public static interface ITargetRespondListener
+ {
+ /**
+ * Invoked when AjaxRequestTarget is about the respond.
+ *
+ * @param target
+ */
+ public void onTargetRespond(AjaxRequestTarget target);
+ };
+
+ private final Set respondListeners = new HashSet();
+
+ /**
+ * Register the given respond listener. The listener's
+ * [EMAIL PROTECTED]
ITargetRespondListener#onTargetRespond(AjaxRequestTarget)} method will be
invoked when
+ * the [EMAIL PROTECTED] AjaxRequestTarget} starts to respond.
+ *
+ * @param listener
+ */
+ public void registerRespondListener(ITargetRespondListener listener)
+ {
+ respondListeners.add(listener);
+ }
+
+ /**
* @see
org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle)
*/
public final void respond(final RequestCycle requestCycle)
{
+ Iterator it = respondListeners.iterator();
+ while (it.hasNext())
+ {
+ ITargetRespondListener listener =
(ITargetRespondListener)it.next();
+ listener.onTargetRespond(this);
+ }
+
final Application app = Application.get();
// Determine encoding
@@ -509,7 +549,7 @@
fireOnBeforeRespondListeners();
// normal behavior
- Iterator it = prependJavascripts.iterator();
+ it = prependJavascripts.iterator();
while (it.hasNext())
{
String js = (String)it.next();
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java?rev=654306&r1=654305&r2=654306&view=diff
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
(original)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
Wed May 7 15:26:45 2008
@@ -53,7 +53,7 @@
*
* @author Matej Knopp
*/
-public abstract class AbstractTree extends Panel implements
ITreeStateListener, TreeModelListener
+public abstract class AbstractTree extends Panel implements
ITreeStateListener, TreeModelListener, AjaxRequestTarget.ITargetRespondListener
{
/**
@@ -880,23 +880,8 @@
target.addComponent(component);
}
- /**
- * Updates the changed portions of the tree using given
AjaxRequestTarget. Call this method if
- * you modified the tree model during an ajax request target and you
want to partially update
- * the component on page. Make sure that the tree model has fired the
proper listener functions.
- * <p>
- * <b>You can only call this method once in a request.</b>
- *
- * @param target
- * Ajax request target used to send the update to the page
- */
- public final void updateTree(final AjaxRequestTarget target)
+ public void onTargetRespond(AjaxRequestTarget target)
{
- if (target == null)
- {
- return;
- }
-
// check whether the model hasn't changed
checkModel();
@@ -992,6 +977,26 @@
updated();
}
}
+
+ /**
+ * Updates the changed portions of the tree using given
AjaxRequestTarget. Call this method if
+ * you modified the tree model during an ajax request target and you
want to partially update
+ * the component on page. Make sure that the tree model has fired the
proper listener functions.
+ * <p>
+ * <b>You can only call this method once in a request.</b>
+ *
+ * @param target
+ * Ajax request target used to send the update to the page
+ */
+ public final void updateTree(final AjaxRequestTarget target)
+ {
+ if (target == null)
+ {
+ return;
+ }
+
+ target.registerRespondListener(this);
+ }
/**
* Returns whether the given node is expanded.