Repository: wicket Updated Branches: refs/heads/master 9e42a9548 -> 446003862
WICKET-6361 MarkupContainer#queue doesn't work in table column Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/44600386 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/44600386 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/44600386 Branch: refs/heads/master Commit: 446003862b96e8c5ff551b26489f2e0751b50db0 Parents: 9e42a95 Author: Andrea Del Bene <[email protected]> Authored: Sat Apr 29 15:09:12 2017 +0200 Committer: Andrea Del Bene <[email protected]> Committed: Sat Apr 29 15:09:35 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/wicket/MarkupContainer.java | 54 +++++++------------- .../wicket/queueing/ComponentQueueingTest.java | 20 ++++++++ 2 files changed, 38 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/44600386/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java index 5baac8b..57ab1c9 100644 --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java @@ -1002,17 +1002,6 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp } Page page = findPage(); - - // if we have a path to page, dequeue any container children. - if (page != null && child instanceof MarkupContainer) - { - MarkupContainer childContainer = (MarkupContainer)child; - // if we are already dequeueing there is no need to dequeue again - if (!childContainer.getRequestFlag(RFLAG_CONTAINER_DEQUEING)) - { - childContainer.dequeue(); - } - } if (page != null) { @@ -1874,42 +1863,35 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp } else { - MarkupContainer containerWithQueue = this; + MarkupContainer queueRegion = (MarkupContainer)findParent(IQueueRegion.class); - // check if there are any parent containers that have queued components, up till our - // queue region - while (containerWithQueue.isQueueEmpty() && - !(containerWithQueue instanceof IQueueRegion)) + if (queueRegion == null) { - containerWithQueue = containerWithQueue.getParent(); - if (containerWithQueue == null) - { - // no queued components are available for dequeuing, so we can stop - return; - } - } - - // when there are no components to be dequeued, just stop - if (containerWithQueue.isQueueEmpty()) return; - - // get the queue region where we are going to dequeue components in - MarkupContainer queueRegion = containerWithQueue; - - // the container with queued components could be a queue region, if not, find the region - // to dequeue in - if (!queueRegion.isQueueRegion()) + } + + MarkupContainer anchestor = this; + boolean hasQueuedChildren = !isQueueEmpty(); + + while (!hasQueuedChildren && anchestor != queueRegion) { - queueRegion = (MarkupContainer)queueRegion.findParent(IQueueRegion.class); + anchestor = anchestor.getParent(); + hasQueuedChildren = !anchestor.isQueueEmpty(); } - - if (queueRegion != null && !queueRegion.getRequestFlag(RFLAG_CONTAINER_DEQUEING)) + + if (hasQueuedChildren && !queueRegion.getRequestFlag(RFLAG_CONTAINER_DEQUEING)) { queueRegion.dequeue(); } } } + @Override + protected void onInitialize() + { + super.onInitialize(); + dequeue(); + } /** * @return {@code true} when one or more components are queued */ http://git-wip-us.apache.org/repos/asf/wicket/blob/44600386/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java b/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java index e889865..fdce742 100644 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java @@ -66,6 +66,26 @@ public class ComponentQueueingTest extends WicketTestCase tester.startPage(p); } + /** + * https://issues.apache.org/jira/browse/WICKET-6361 + */ + @Test + public void dequeueComponentsOnInitialization() + { + TestPage p = new TestPage(); + p.setPageMarkup("<p wicket:id='a'><p wicket:id='b'><p wicket:id='c'></p></p></p>"); + MarkupContainer a = new A(), b = new B(), c = new C(); + + //components are queued before their nested container is added to the page. + //this caused a "Detach called on component...while it had a non-empty queue" before WICKET-6361 was fixed + b.queue(c); + a.add(b); + + p.add(a); + + tester.startPage(p); + } + /** {@code [a[b,c]] -> [a[b[c]]] } */ @Test public void dequeue2()
