Repository: wicket Updated Branches: refs/heads/wicket-7.x d647925d1 -> 70342df0f
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/70342df0 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/70342df0 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/70342df0 Branch: refs/heads/wicket-7.x Commit: 70342df0f5d0c87e4a0c335dbf68a699359dd469 Parents: d647925 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 19:59:11 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/70342df0/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 bb85007..d06aabf 100644 --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java @@ -1035,17 +1035,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) { @@ -2001,42 +1990,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/70342df0/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()
