This is an automated email from the ASF dual-hosted git repository. svenmeier pushed a commit to branch remove-queuing in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 070cb953b9afb13b3c6a21236cc9169d79a9b2d6 Author: Sven Meier <svenme...@apache.org> AuthorDate: Wed Jun 2 23:06:39 2021 +0200 removed queuing --- .../java/org/apache/wicket/ChildToDequeueType.java | 49 - .../java/org/apache/wicket/DequeueContext.java | 301 ------ .../java/org/apache/wicket/DequeueTagAction.java | 27 - .../main/java/org/apache/wicket/IQueueRegion.java | 61 -- .../java/org/apache/wicket/MarkupContainer.java | 348 ------ .../src/main/java/org/apache/wicket/Page.java | 3 +- .../apache/wicket/markup/html/border/Border.java | 147 +-- .../markup/html/form/FormComponentPanel.java | 3 +- .../apache/wicket/markup/html/panel/Fragment.java | 17 +- .../org/apache/wicket/markup/html/panel/Panel.java | 26 +- .../wicket/markup/repeater/AbstractRepeater.java | 32 +- .../apache/wicket/BehavioursDetachTestPage.java | 2 +- .../apache/wicket/OnComponentTagListenerTest.java | 5 +- .../markup/html/border/BorderWithFormPage.java | 40 - .../markup/html/border/ComponentBorderTest.java | 24 - .../markup/html/internal/AjaxEnclosurePage_4.java | 8 +- .../html/internal/ListViewInContainerPage.java | 4 +- .../wicket/markupFragments/MarkupFragmentTest.java | 3 - .../queueing/ComponentQueueingPerformanceTest.java | 400 ------- .../wicket/queueing/ComponentQueueingTest.java | 1135 -------------------- .../queueing/transparentresolvers/SubPage.java | 2 +- .../TransparentContainerQueuePage.java | 2 +- .../ajax/builtin/modal/ModalDialogPage.java | 39 +- 23 files changed, 42 insertions(+), 2636 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/ChildToDequeueType.java b/wicket-core/src/main/java/org/apache/wicket/ChildToDequeueType.java deleted file mode 100644 index 29cfdfe..0000000 --- a/wicket-core/src/main/java/org/apache/wicket/ChildToDequeueType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket; - -import org.apache.wicket.markup.html.border.Border; - -public enum ChildToDequeueType -{ - NULL, GENERIC_COMPONENT, MARKUP_CONTAINER, BORDER, QUEUE_REGION; - - public static ChildToDequeueType fromChild(Component child) - { - if (child == null) - { - return NULL; - } - - if (child instanceof Border) - { - return BORDER; - } - - if (child instanceof IQueueRegion) - { - return QUEUE_REGION; - } - - if (child instanceof MarkupContainer) - { - return MARKUP_CONTAINER; - } - - return GENERIC_COMPONENT; - } -} diff --git a/wicket-core/src/main/java/org/apache/wicket/DequeueContext.java b/wicket-core/src/main/java/org/apache/wicket/DequeueContext.java deleted file mode 100644 index 9c431e9..0000000 --- a/wicket-core/src/main/java/org/apache/wicket/DequeueContext.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket; - -import java.util.ArrayDeque; - -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.IMarkupFragment; -import org.apache.wicket.markup.MarkupElement; - -/** - * Context for component dequeueing. Keeps track of markup position and container stack. - * - * @author igor - * - */ -public final class DequeueContext -{ - private final IMarkupFragment markup; - private int index; - private ComponentTag next; - private ArrayDeque<ComponentTag> tags = new ArrayDeque<>(); - private final boolean skipFirst; - private ComponentTag first; - - private ArrayDeque<MarkupContainer> containers = new ArrayDeque<>(); - - /** A bookmark for the DequeueContext stack */ - public static final class Bookmark - { - private final int index; - private final ComponentTag next; - private final ArrayDeque<ComponentTag> tags; - private final ArrayDeque<MarkupContainer> containers; - - private Bookmark(DequeueContext parser) - { - this.index = parser.index; - this.next = parser.next; - this.tags = new ArrayDeque<>(parser.tags); - this.containers = new ArrayDeque<>(parser.containers); - } - - private void restore(DequeueContext parser) - { - parser.index = index; - parser.next = next; - parser.tags = new ArrayDeque<>(tags); - parser.containers = new ArrayDeque<>(containers); - } - } - - public DequeueContext(IMarkupFragment markup, MarkupContainer root, boolean skipFirst) - { - this.markup = markup; - this.skipFirst = skipFirst; - this.containers.push(root); - this.next = nextTag(); - } - - /** - * Saves the state of the context into a bookmark which can later be used to restore it. - */ - public Bookmark save() - { - return new Bookmark(this); - } - - /** - * Restores the state of the context from the bookmark - * - * @param bookmark - */ - public void restore(Bookmark bookmark) - { - bookmark.restore(this); - } - - /** - * Peeks markup tag that would be retrieved by call to {@link #takeTag()} - * - * @return - */ - public ComponentTag peekTag() - { - return next; - } - - /** - * Retrieves the next markup tag - * - * @return - */ - public ComponentTag takeTag() - { - ComponentTag taken = next; - - if (taken == null) - { - return null; - } - - if (taken.isOpen() && !taken.hasNoCloseTag()) - { - tags.push(taken); - } - else if (tags.size() > 0 && taken.closes(tags.peek())) - { - tags.pop(); - } - next = nextTag(); - return taken; - } - - /** - * Skips to the closing tag of the tag retrieved from last call to {@link #takeTag()} - */ - public void skipToCloseTag() - { - while (!next.closes(tags.peek())) - { - next = nextTag(); - } - } - - private ComponentTag nextTag() - { - if (skipFirst && first == null) - { - for (; index < markup.size(); index++) - { - MarkupElement element = markup.get(index); - if (element instanceof ComponentTag) - { - first = (ComponentTag)element; - index++; - break; - } - } - } - - for (; index < markup.size(); index++) - { - MarkupElement element = markup.get(index); - if (element instanceof ComponentTag) - { - ComponentTag tag = (ComponentTag)element; - - if (tag.isOpen() || tag.isOpenClose()) - { - DequeueTagAction action = canDequeueTag(tag); - switch (action) - { - case IGNORE : - continue; - case DEQUEUE : - index++; - return tag; - case SKIP : // skip to close tag - boolean found = false; - for (; index < markup.size(); index++) - { - if ((markup.get(index) instanceof ComponentTag) - && markup.get(index).closes(tag)) - { - found = true; - break; - } - } - if (!found) - { - throw new IllegalStateException(String.format( - "Could not find close tag for tag '%s' in markup: %s ", tag, - markup)); - } - - } - } - else - { - // closed tag - ComponentTag open = tag.isClose() ? tag.getOpenTag() : tag; - - if (skipFirst && first != null && open == first) - { - continue; - } - - switch (canDequeueTag(open)) - { - case DEQUEUE : - index++; - return tag; - case IGNORE : - continue; - case SKIP : - throw new IllegalStateException(String.format( - "Should not see closed tag of skipped open tag '%s' in markup:%s", - tag, markup)); - } - } - } - } - return null; - } - - private DequeueTagAction canDequeueTag(ComponentTag open) - { - if (containers.size() < 1) - { - // TODO queueing message: called too early - throw new IllegalStateException(); - } - - DequeueTagAction action; - for (MarkupContainer container : containers) - { - action = container.canDequeueTag(open); - if (action != null) - { - return action; - } - } - return DequeueTagAction.IGNORE; - } - - /** - * Checks if the tag returned by {@link #peekTag()} is either open or open-close. - * - * @return - */ - public boolean isAtOpenOrOpenCloseTag() - { - ComponentTag tag = peekTag(); - return tag != null && (tag.isOpen() || tag.isOpenClose()); - } - - /** - * Retrieves the container on the top of the containers stack - * - * @return - */ - public MarkupContainer peekContainer() - { - return containers.peek(); - } - - /** - * Pushes a container onto the container stack - * - * @param container - */ - public void pushContainer(MarkupContainer container) - { - containers.push(container); - } - - /** - * Pops a container from the container stack - * - * @return - */ - public MarkupContainer popContainer() - { - return containers.pop(); - } - - /** - * Searches the container stack for a component that can be dequeude - * - * @param tag - * @return - */ - public Component findComponentToDequeue(ComponentTag tag) - { - for (MarkupContainer container : containers) - { - Component child = container.findComponentToDequeue(tag); - if (child != null) - { - return child; - } - } - return null; - } - -} diff --git a/wicket-core/src/main/java/org/apache/wicket/DequeueTagAction.java b/wicket-core/src/main/java/org/apache/wicket/DequeueTagAction.java deleted file mode 100644 index 461cac4..0000000 --- a/wicket-core/src/main/java/org/apache/wicket/DequeueTagAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket; - -public enum DequeueTagAction -{ - /** dequeue the tag */ - DEQUEUE, - /** skip this tag and all its children */ - SKIP, - /** ignore this tag, skip it but do not skip its children */ - IGNORE; -} diff --git a/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java b/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java deleted file mode 100644 index b6ef154..0000000 --- a/wicket-core/src/main/java/org/apache/wicket/IQueueRegion.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket; - -import org.apache.wicket.markup.IMarkupFragment; - - -/** - * Demarcates components that act as a root can dequeue children. These are usually components with - * associated markup since the markup is needed to dequeue. - * - * It is also important to note that components queued outside of a region cannot be dequeued into - * it since regions act as roots for the dequeue process because they contain the markup. As such, - * for example, a component queued in a page cannot be dequeued into a page child that is a panel - * because a panel is an {@link IQueueRegion}. - * - * @author igor - * - */ -public interface IQueueRegion -{ - /** - * Creates a new {@link DequeueContext} that will be used to dequeue children of this region. - * - * Usually containers will create a context with their associated markup by getting it via - * {@link MarkupContainer#getAssociatedMarkup()}, but components that do not render markup in a - * standard way (such as repeaters and borders) may choose to override this method to implement - * custom behavior for the dequeueing process. - */ - DequeueContext newDequeueContext(); - - /** - * Starts component dequeueing on this {@link IQueueRegion}. This is the entry point into the - * dequeuing process, it creates the {@link DequeueContext} and delegates the operation to the - * {@link org.apache.wicket.MarkupContainer#dequeue(DequeueContext)} method which performs the - * actual dequeueing. The context's markup is retrieved using the {@link MarkupContainer#getAssociatedMarkup()}. - */ - void dequeue(); - - /** - * Returns the markup to use for queuing. Normally, this is the markup of the component - * implementing this interface. - * - * @return the markup to use for queuing - */ - IMarkupFragment getRegionMarkup(); -} 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 e095319..007593a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java @@ -35,7 +35,6 @@ import org.apache.commons.collections4.map.LinkedMap; import org.apache.wicket.behavior.OutputMarkupContainerClassNameBehavior; import org.apache.wicket.core.util.string.ComponentStrings; import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.ComponentTag.IAutoComponentFactory; import org.apache.wicket.markup.IMarkupFragment; import org.apache.wicket.markup.Markup; import org.apache.wicket.markup.MarkupElement; @@ -46,7 +45,6 @@ import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.MarkupType; import org.apache.wicket.markup.WicketTag; import org.apache.wicket.markup.html.border.Border; -import org.apache.wicket.markup.html.form.AutoLabelResolver; import org.apache.wicket.markup.resolver.ComponentResolvers; import org.apache.wicket.model.IComponentInheritedModel; import org.apache.wicket.model.IModel; @@ -1780,186 +1778,6 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp modCounter++; removals_clear(); - - if (queue != null && !queue.isEmpty() && hasBeenRendered()) - { - throw new WicketRuntimeException( - String.format("Detach called on component with id '%s' while it had a non-empty queue: %s", - getId(), queue)); - } - } - - private transient ComponentQueue queue; - - /** - * Queues one or more components to be dequeued later. The advantage of this method over the - * {@link #add(Component...)} method is that the component does not have to be added to its - * direct parent, only to a parent upstream; it will be dequeued into the correct parent using - * the hierarchy defined in the markup. This allows the component hierarchy to be maintained only - * in markup instead of in markup and in java code; affording designers and developers more - * freedom when moving components in markup. - * - * @param components - * the components to queue - * @return {@code this} for method chaining - */ - public MarkupContainer queue(Component... components) - { - if (queue == null) - { - queue = new ComponentQueue(); - } - queue.add(components); - - Page page = findPage(); - - if (page != null) - { - dequeue(); - } - - return this; - } - - /** - * @see IQueueRegion#dequeue() - */ - public void dequeue() - { - if (this instanceof IQueueRegion) - { - DequeueContext dequeue = newDequeueContext(); - dequeuePreamble(dequeue); - } - else - { - MarkupContainer queueRegion = (MarkupContainer)findParent(IQueueRegion.class); - - if (queueRegion == null) - { - return; - } - - MarkupContainer anchestor = this; - boolean hasQueuedChildren = !isQueueEmpty(); - - while (!hasQueuedChildren && anchestor != queueRegion) - { - anchestor = anchestor.getParent(); - hasQueuedChildren = !anchestor.isQueueEmpty(); - } - - 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 - */ - private boolean isQueueEmpty() - { - return queue == null || queue.isEmpty(); - } - - /** - * @return {@code true} when this markup container is a queue region - */ - private boolean isQueueRegion() - { - return IQueueRegion.class.isInstance(this); - } - - /** - * Run preliminary operations before running {@link #dequeue(DequeueContext)}. More in detail it - * throws an exception if the container is already dequeuing, and it also takes care of setting - * flag {@code RFLAG_CONTAINER_DEQUEING} to true before running {@link #dequeue(DequeueContext)} - * and setting it back to false after dequeuing is completed. - * - * @param dequeue - * the dequeue context to use - */ - protected void dequeuePreamble(DequeueContext dequeue) - { - if (getRequestFlag(RFLAG_CONTAINER_DEQUEING)) - { - throw new IllegalStateException("This container is already dequeing: " + this); - } - - setRequestFlag(RFLAG_CONTAINER_DEQUEING, true); - try - { - if (dequeue == null) - { - return; - } - - if (dequeue.peekTag() != null) - { - dequeue(dequeue); - } - } - finally - { - setRequestFlag(RFLAG_CONTAINER_DEQUEING, false); - } - } - - /** - * Dequeues components. The default implementation iterates direct children of this container - * found in its markup and tries to find matching - * components in queues filled by a call to {@link #queue(Component...)}. It then delegates the - * dequeueing to these children. - * - * - * Certain components that implement custom markup behaviors (such as repeaters and borders) - * override this method to bring dequeueing in line with their custom markup handling. - * - * @param dequeue - * the dequeue context to use - */ - public void dequeue(DequeueContext dequeue) - { - while (dequeue.isAtOpenOrOpenCloseTag()) - { - ComponentTag tag = dequeue.takeTag(); - - // see if child is already added to parent - Component child = findChildComponent(tag); - - if (child == null) - { - // the container does not yet have a child with this id, see if we can - // dequeue - child = dequeue.findComponentToDequeue(tag); - - //if tag has an autocomponent factory let's use it - if (child == null && tag.getAutoComponentFactory() != null) - { - IAutoComponentFactory autoComponentFactory = tag.getAutoComponentFactory(); - child = autoComponentFactory.newComponent(this, tag); - } - - if (child != null) - { - addDequeuedComponent(child, tag); - } - } - - if (tag.isOpen() && !tag.hasNoCloseTag()) - { - dequeueChild(child, tag, dequeue); - } - } - } /** @@ -1975,172 +1793,6 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp } /** - * Propagates dequeuing to child component. - * - * @param child - * the child component - * @param tag - * the child tag - * @param dequeue - * the dequeue context to use - */ - private void dequeueChild(Component child, ComponentTag tag, DequeueContext dequeue) - { - ChildToDequeueType childType = ChildToDequeueType.fromChild(child); - - if (childType == ChildToDequeueType.QUEUE_REGION || - childType == ChildToDequeueType.BORDER) - { - ((IQueueRegion)child).dequeue(); - } - - if (childType == ChildToDequeueType.BORDER) - { - Border childContainer = (Border)child; - // propagate dequeuing to border's body - MarkupContainer body = childContainer.getBodyContainer(); - - dequeueChildrenContainer(dequeue, body); - } - - if (childType == ChildToDequeueType.MARKUP_CONTAINER) - { - // propagate dequeuing to containers - MarkupContainer childContainer = (MarkupContainer)child; - - dequeueChildrenContainer(dequeue, childContainer); - } - - if (childType == ChildToDequeueType.NULL || - childType == ChildToDequeueType.QUEUE_REGION) - { - dequeue.skipToCloseTag(); - } - - // pull the close tag off - ComponentTag close = dequeue.takeTag(); - do - { - if (close != null && close.closes(tag)) - { - return; - } - } while ((close = dequeue.takeTag()) != null); - - throw new IllegalStateException(String.format("Could not find the closing tag for '%s'", tag)); - } - - private void dequeueChildrenContainer(DequeueContext dequeue, MarkupContainer child) - { - dequeue.pushContainer(child); - child.dequeue(dequeue); - dequeue.popContainer(); - } - - /** @see IQueueRegion#newDequeueContext() */ - public DequeueContext newDequeueContext() - { - IMarkupFragment markup = getRegionMarkup(); - if (markup == null) - { - return null; - } - - return new DequeueContext(markup, this, false); - } - - /** @see IQueueRegion#getRegionMarkup() */ - public IMarkupFragment getRegionMarkup() - { - return getAssociatedMarkup(); - } - - /** - * Checks if this container can dequeue a child represented by the specified tag. This method - * should be overridden when containers can dequeue components represented by non-standard tags. - * For example, borders override this method and dequeue their body container when processing - * the body tag. - * - * By default all {@link ComponentTag}s are supported as well as {@link WicketTag}s that return - * a non-null value from {@link WicketTag#getAutoComponentFactory()} method. - * - * @param tag - */ - protected DequeueTagAction canDequeueTag(ComponentTag tag) - { - if (tag instanceof WicketTag) - { - WicketTag wicketTag = (WicketTag)tag; - if (wicketTag.isContainerTag()) - { - return DequeueTagAction.DEQUEUE; - } - else if (wicketTag.getAutoComponentFactory() != null) - { - return DequeueTagAction.DEQUEUE; - } - else if (wicketTag.isFragmentTag()) - { - return DequeueTagAction.SKIP; - } - else if (wicketTag.isChildTag()) - { - return DequeueTagAction.IGNORE; - } - else if (wicketTag.isHeadTag()) - { - return DequeueTagAction.SKIP; - } - else if (wicketTag.isLinkTag()) - { - return DequeueTagAction.DEQUEUE; - } - else - { - return null; // don't know - } - } - - //if is a label tag, ignore it - if (tag.isAutoComponentTag() - && tag.getId().startsWith(AutoLabelResolver.LABEL_ATTR)) - { - return DequeueTagAction.IGNORE; - } - - return DequeueTagAction.DEQUEUE; - } - - /** - * Queries this container to find a child that can be dequeued that matches the specified tag. - * The default implementation will check if there is a component in the queue that has the same - * id as a tag, but sometimes custom tags can be dequeued and in those situations this method - * should be overridden. - * - * @param tag - * @return - */ - public Component findComponentToDequeue(ComponentTag tag) - { - return queue == null ? null : queue.remove(tag.getId()); - } - - /** - * Adds a dequeued component to this container. This method should rarely be overridden because - * the common case of simply forwarding the component to - * {@link MarkupContainer#add(Component...)} method should cover most cases. Components that - * implement a custom hierarchy, such as borders, may wish to override it to support edge-case - * non-standard behavior. - * - * @param component - * @param tag - */ - protected void addDequeuedComponent(Component component, ComponentTag tag) - { - add(component); - } - - /** * Returns a sequential {@code Stream} with the direct children of this markup container as its * source. This stream doesn't traverse the component tree. * diff --git a/wicket-core/src/main/java/org/apache/wicket/Page.java b/wicket-core/src/main/java/org/apache/wicket/Page.java index d204335..180bc54 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Page.java +++ b/wicket-core/src/main/java/org/apache/wicket/Page.java @@ -84,8 +84,7 @@ import org.slf4j.LoggerFactory; */ public abstract class Page extends MarkupContainer implements - IRequestablePage, - IQueueRegion + IRequestablePage { /** True if the page hierarchy has been modified in the current request. */ private static final int FLAG_IS_DIRTY = FLAG_RESERVED3; diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java index 1feea65..b36f3e5 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java @@ -17,9 +17,6 @@ package org.apache.wicket.markup.html.border; import org.apache.wicket.Component; -import org.apache.wicket.DequeueContext; -import org.apache.wicket.DequeueTagAction; -import org.apache.wicket.IQueueRegion; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.IMarkupFragment; @@ -28,8 +25,6 @@ import org.apache.wicket.markup.MarkupException; import org.apache.wicket.markup.MarkupFragment; import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.TagUtils; -import org.apache.wicket.markup.WicketTag; -import org.apache.wicket.markup.html.MarkupUtil; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.panel.BorderMarkupSourcingStrategy; import org.apache.wicket.markup.html.panel.IMarkupSourcingStrategy; @@ -137,7 +132,7 @@ import org.apache.wicket.util.lang.Args; * @author Jonathan Locke * @author Juergen Donnerstag */ -public abstract class Border extends WebMarkupContainer implements IComponentResolver, IQueueRegion +public abstract class Border extends WebMarkupContainer implements IComponentResolver { private static final long serialVersionUID = 1L; @@ -166,7 +161,7 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes super(id, model); body = new BorderBodyContainer(id + "_" + BODY); - queueToBorder(body); + addToBorder(body); } /** @@ -313,33 +308,6 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes return this; } - @Override - public Border queue(Component... components) - { - getBodyContainer().queue(components); - return this; - } - - @Override - protected void onConfigure() - { - super.onConfigure(); - dequeue(); - } - - /** - * Queues children components to the Border itself - * - * @param children - * the children components to queue - * @return this - */ - public Border queueToBorder(final Component... children) - { - super.queue(children); - return this; - } - /** * Removes child from the Border itself * @@ -455,7 +423,7 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes /** * The container to be associated with the <wicket:body> tag */ - public class BorderBodyContainer extends WebMarkupContainer implements IQueueRegion + public class BorderBodyContainer extends WebMarkupContainer { private static final long serialVersionUID = 1L; @@ -592,112 +560,5 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes return markup.find(child.getId()); } - - @Override - public DequeueContext newDequeueContext() - { - Border border = findParent(Border.class); - IMarkupFragment fragment = border.getMarkup(); - - if (fragment == null) - { - return null; - } - - return new DequeueContext(fragment, this, true); - } - - @Override - public Component findComponentToDequeue(ComponentTag tag) - { - /* - * the body container is allowed to search for queued components all - * the way to the page even though it is an IQueueRegion so it can - * find components queued below the border - */ - - Component component = super.findComponentToDequeue(tag); - if (component != null) - { - return component; - } - - MarkupContainer cursor = getParent(); - while (cursor != null) - { - component = cursor.findComponentToDequeue(tag); - if (component != null) - { - return component; - } - if (cursor instanceof BorderBodyContainer) - { - // optimization - find call above would've already recursed - // to page - break; - } - cursor = cursor.getParent(); - } - return null; - } - } - - @Override - protected DequeueTagAction canDequeueTag(ComponentTag tag) - { - if (canDequeueBody(tag)) - { - return DequeueTagAction.DEQUEUE; - } - - return super.canDequeueTag(tag); - } - - @Override - public Component findComponentToDequeue(ComponentTag tag) - { - if (canDequeueBody(tag)) - { - //synch the tag id with the one of the body component - tag.setId(body.getId()); - } - - return super.findComponentToDequeue(tag); - } - - private boolean canDequeueBody(ComponentTag tag) - { - boolean isBodyTag = (tag instanceof WicketTag) && ((WicketTag)tag).isBodyTag(); - - return isBodyTag; - } - - @Override - protected void addDequeuedComponent(Component component, ComponentTag tag) - { - // components queued in border get dequeued into the border not into the body container - super.add(component); - } - - /** - * Returns the markup inside <wicket:border> tag. - * If such tag is not found, all the markup is returned. - * - * @see IQueueRegion#getRegionMarkup() - */ - @Override - public IMarkupFragment getRegionMarkup() - { - IMarkupFragment markup = super.getRegionMarkup(); - - if (markup == null) - { - return markup; - } - - IMarkupFragment borderMarkup = MarkupUtil.findStartTag(markup, BORDER); - - return borderMarkup != null ? borderMarkup : markup; } - -} +} \ No newline at end of file diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java index 5fe284f..b8b661b 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java @@ -16,7 +16,6 @@ */ package org.apache.wicket.markup.html.form; -import org.apache.wicket.IQueueRegion; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.html.panel.IMarkupSourcingStrategy; import org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy; @@ -109,7 +108,7 @@ import org.apache.wicket.util.visit.IVisitor; * @param <T> * The model object type */ -public abstract class FormComponentPanel<T> extends FormComponent<T> implements IQueueRegion +public abstract class FormComponentPanel<T> extends FormComponent<T> { private static final long serialVersionUID = 1L; diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java index 25e9b10..3b3ae58 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java @@ -17,8 +17,6 @@ package org.apache.wicket.markup.html.panel; import org.apache.wicket.Component; -import org.apache.wicket.DequeueContext; -import org.apache.wicket.IQueueRegion; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.IMarkupFragment; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -48,7 +46,7 @@ import org.apache.wicket.util.lang.Args; * * @author Juergen Donnerstag */ -public class Fragment extends WebMarkupContainer implements IQueueRegion +public class Fragment extends WebMarkupContainer { private static final long serialVersionUID = 1L; @@ -131,17 +129,4 @@ public class Fragment extends WebMarkupContainer implements IQueueRegion { return associatedMarkupId; } - - - @Override - public DequeueContext newDequeueContext() - { - IMarkupFragment markup = getMarkupSourcingStrategy().getMarkup(this, null); - if (markup == null) - { - return null; - } - - return new DequeueContext(markup, this, true); - } } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java index 1520c07..7926b99 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/Panel.java @@ -16,7 +16,6 @@ */ package org.apache.wicket.markup.html.panel; -import org.apache.wicket.IQueueRegion; import org.apache.wicket.markup.IMarkupFragment; import org.apache.wicket.markup.html.MarkupUtil; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -52,7 +51,7 @@ import org.apache.wicket.model.IModel; * @author Jonathan Locke * @author Juergen Donnerstag */ -public abstract class Panel extends WebMarkupContainer implements IQueueRegion +public abstract class Panel extends WebMarkupContainer { private static final long serialVersionUID = 1L; @@ -83,25 +82,4 @@ public abstract class Panel extends WebMarkupContainer implements IQueueRegion { return new PanelMarkupSourcingStrategy(false); } - - /** - * Returns the markup inside <wicket:panel> tag. - * If such tag is not found, all the markup is returned. - * - * @see IQueueRegion#getRegionMarkup() - */ - @Override - public IMarkupFragment getRegionMarkup() - { - IMarkupFragment markup = super.getRegionMarkup(); - - if (markup == null) - { - return markup; - } - - IMarkupFragment panelMarkup = MarkupUtil.findStartTag(markup, PANEL); - - return panelMarkup != null ? panelMarkup : markup; - } -} +} \ No newline at end of file diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/repeater/AbstractRepeater.java b/wicket-core/src/main/java/org/apache/wicket/markup/repeater/AbstractRepeater.java index 25e320a..3ea03ea 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/repeater/AbstractRepeater.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/repeater/AbstractRepeater.java @@ -21,9 +21,6 @@ import java.util.Iterator; import java.util.Set; import org.apache.wicket.Component; -import org.apache.wicket.DequeueContext; -import org.apache.wicket.DequeueContext.Bookmark; -import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.IMarkupFragment; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.model.IModel; @@ -158,31 +155,4 @@ public abstract class AbstractRepeater extends WebMarkupContainer */ protected abstract void onPopulate(); - @Override - public void dequeue(DequeueContext dequeue) - { - if (size() > 0) - { - // essentially what we do is for every child replace the repeater with the child in - // dequeue container stack and run the dequeue on the child. we also take care to reset - // the state of the dequeue context after we process every child. - - Bookmark bookmark = dequeue.save(); - - for (Component child : this) - { - if (child instanceof MarkupContainer) - { - dequeue.popContainer(); // pop the repeater - MarkupContainer container = (MarkupContainer) child; - dequeue.pushContainer(container); - container.dequeue(dequeue); - dequeue.restore(bookmark); - } - } - } - - dequeue.skipToCloseTag(); - - } -} +} \ No newline at end of file diff --git a/wicket-core/src/test/java/org/apache/wicket/BehavioursDetachTestPage.java b/wicket-core/src/test/java/org/apache/wicket/BehavioursDetachTestPage.java index 82b8f73..75b2923 100644 --- a/wicket-core/src/test/java/org/apache/wicket/BehavioursDetachTestPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/BehavioursDetachTestPage.java @@ -39,7 +39,7 @@ public class BehavioursDetachTestPage extends WebPage { @Override public void onClick() {/*NoOp*/} }; - queue(link); + add(link); // A behavior that causes the problem link.add(new VisibilityBehavior()); diff --git a/wicket-core/src/test/java/org/apache/wicket/OnComponentTagListenerTest.java b/wicket-core/src/test/java/org/apache/wicket/OnComponentTagListenerTest.java index 0a588a0..1c57571 100644 --- a/wicket-core/src/test/java/org/apache/wicket/OnComponentTagListenerTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/OnComponentTagListenerTest.java @@ -102,13 +102,14 @@ class OnComponentTagListenerTest extends WicketTestCase { static class TestPage extends WebPage implements IMarkupResourceStreamProvider { private static final long serialVersionUID = 1L; - private Component c1, c2, c3; + private WebMarkupContainer c1, c2, c3; TestPage() { c1 = new WebMarkupContainer("c1"); c2 = new WebMarkupContainer("c2"); c3 = new WebMarkupContainer("c3"); - queue(c1, c2, c3); + add(c1, c3); + c1.add(c2); } @Override diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithFormPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithFormPage.java deleted file mode 100644 index e48567c..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithFormPage.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.markup.html.border; - -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.IModel; - -public class BorderWithFormPage extends WebPage { - private static final long serialVersionUID = 1L; - private TextField<String> field; - - public BorderWithFormPage(IModel<String> model) { - super(); - - WebMarkupContainer container = new WebMarkupContainer("borderContainer"); - - BorderWithForm border = new BorderWithForm("formBorder"); - - border.add(field = new TextField<>("text", model)); - - container.add(border); - add(container); - } -} diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java index 51c1f63..b805762 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java @@ -89,30 +89,6 @@ class ComponentBorderTest extends WicketTestCase } @Test - void borderWithForm() throws Exception - { - /* - * Suppose we have a border like this: - * - * <div wicket:id="border"> <form> <body/> </form> </div> - * - * Any form components inside its body must be correctly submitted with the outer form. - */ - Model<String> model = Model.of(""); - BorderWithFormPage page = new BorderWithFormPage(model); - - tester.startPage(page); - - FormTester formTester = tester - .newFormTester("borderContainer:formBorder:borderContainer:form"); - - formTester.setValue("formBorder_body:text", TEST_TEXT); - formTester.submit(); - - assertEquals(TEST_TEXT, model.getObject()); - } - - @Test void borderWithEnclosurePage() throws Exception { tester.startPage(BorderWithEnclosurePage.class); diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java index bdeb27d..51fec72 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java @@ -17,10 +17,8 @@ package org.apache.wicket.markup.html.internal; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; @@ -49,14 +47,14 @@ public class AjaxEnclosurePage_4 extends WebPage { Form<?> form=new Form<Void>("form"); - queue(form); + add(form); //nameLabel=new Label("nameLabel", "Name"); //queue(nameLabel); nameField=new TextField<String>("nameField", new PropertyModel<String>(this, "name")); nameField.setOutputMarkupId(true); - queue(nameField); + form.add(nameField); submit=new AjaxSubmitLink("submit") { @Override @@ -66,7 +64,7 @@ public class AjaxEnclosurePage_4 extends WebPage target.add(nameField); } }; - queue(submit); + form.add(submit); } diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/ListViewInContainerPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/ListViewInContainerPage.java index cb9787f..ee38514 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/ListViewInContainerPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/ListViewInContainerPage.java @@ -50,10 +50,10 @@ public class ListViewInContainerPage extends BasePage protected void populateItem(final ListItem<Integer> item) { final Label testenc = new Label("testenc", Model.of("enclosure " + item.getModelObject())); - item.queue(testenc); + item.add(testenc); final Label testlib = new Label("testlib", Model.of("no enclosure " + item.getModelObject())); - item.queue(testlib); + item.add(testlib); } }); } diff --git a/wicket-core/src/test/java/org/apache/wicket/markupFragments/MarkupFragmentTest.java b/wicket-core/src/test/java/org/apache/wicket/markupFragments/MarkupFragmentTest.java index 1a2a86f..78c54d4 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markupFragments/MarkupFragmentTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markupFragments/MarkupFragmentTest.java @@ -180,7 +180,6 @@ class MarkupFragmentTest extends WicketTestCase assertNull(border.getBodyContainer().getAssociatedMarkup()); - border.dequeue(); markup = border.getBodyContainer().getMarkup(); compareMarkupWithString(markup, "<wicket:body/>"); @@ -220,8 +219,6 @@ class MarkupFragmentTest extends WicketTestCase assertNull(border.getBodyContainer().getAssociatedMarkup()); - // See explanation in BaseBorder.BorderBodyContainer.getMarkup() - border.dequeue(); markup = border.getBodyContainer().getParent().getMarkup(border.getBodyContainer()); compareMarkupWithString(markup, "<wicket:body>333</wicket:body>"); diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingPerformanceTest.java b/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingPerformanceTest.java deleted file mode 100644 index 722478e..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingPerformanceTest.java +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.queueing; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; - -import org.apache.wicket.MarkupContainer; -import org.apache.wicket.Page; -import org.apache.wicket.markup.IMarkupResourceStreamProvider; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.RefreshingView; -import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter; -import org.apache.wicket.mock.MockApplication; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.util.WicketTestTag; -import org.apache.wicket.util.resource.IResourceStream; -import org.apache.wicket.util.resource.StringResourceStream; -import org.apache.wicket.util.tester.WicketTestCase; -import org.apache.wicket.util.tester.WicketTester; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -@Tag(WicketTestTag.SLOW) -public class ComponentQueueingPerformanceTest extends WicketTestCase -{ - private void run(Class<? extends Page> pageClass) - { - WicketTester tester = new WicketTester(new MockApplication()); - try - { - tester.startPage(pageClass); - } - finally - { - tester.destroy(); - } - } - - @Test - void performance() - { - final int warmup = 30; - final int performance = 60; - - tester.startPage(AddContactsPage.class); - - for (int i = 0; i < warmup; i++) - { - run(AddContactsPage.class); - } - long start = System.currentTimeMillis(); - for (int i = 0; i < performance; i++) - { - run(AddContactsPage.class); - } - long end = System.currentTimeMillis(); - long addDuration = end - start; - - for (int i = 0; i < warmup; i++) - { - run(QueueContactsPage.class); - } - start = System.currentTimeMillis(); - for (int i = 0; i < performance; i++) - { - run(QueueContactsPage.class); - } - end = System.currentTimeMillis(); - long queueDuration = end - start; - - - System.out.println("add duration: " + addDuration + " queue duration: " + queueDuration); - - } - - - @Test - void consistency() - { - tester.startPage(new QueueContactsPage()); - String queue = tester.getLastResponseAsString(); - tester.startPage(new AddContactsPage()); - String add = tester.getLastResponseAsString(); - assertEquals(queue, add); - } - - private static class PhoneNumber - { - String id = UUID.randomUUID().toString(); - String areacode = "234"; - String prefix = "342"; - String suffix = "3423"; - } - - private static class Address - { - String id = UUID.randomUUID().toString(); - String street = "2343 Jsdfjsf St."; - String city = "Ksdfjsfs"; - String state = "AS"; - String zipcode = "32434"; - } - - private static class Contact - { - String id = UUID.randomUUID().toString(); - String first = "Jlkjsf"; - String last = "Kjwieojkjf"; - Address address = new Address(); - PhoneNumber work = new PhoneNumber(); - PhoneNumber cell = new PhoneNumber(); - - } - - private static Store store = new Store(); - - private static class Store - { - Map<String, PhoneNumber> phones = new HashMap<String, PhoneNumber>(); - Map<String, Address> addresses = new HashMap<String, Address>(); - Map<String, Contact> contacts = new HashMap<String, Contact>(); - - public <T> T get(Class<T> clazz, String id) - { - if (PhoneNumber.class.equals(clazz)) - { - return (T)phones.get(id); - } - else if (Address.class.equals(clazz)) - { - return (T)addresses.get(id); - } - else if (Contact.class.equals(clazz)) - { - return (T)contacts.get(id); - } - throw new RuntimeException(); - } - - Store() - { - for (int i = 0; i < 250; i++) - { - Contact contact = new Contact(); - contacts.put(contact.id, contact); - } - } - - } - - private static class ContactModel extends LoadableDetachableModel<Contact> - { - private String id; - - ContactModel(Contact contact) - { - super(contact); - this.id = contact.id; - } - - @Override - protected Contact load() - { - return store.contacts.get(id); - } - - } - - private static abstract class AbstractPhonePanel extends TestPanel - { - AbstractPhonePanel(String id, IModel<PhoneNumber> phone) - { - super(id); - setPanelMarkup("<wicket:panel><span wicket:id='areacode'></span> <span wicket:id='prefix'></span>-<span wicket:id='suffix'></span></wicket:panel>"); - } - } - - private static class AddPhonePanel extends AbstractPhonePanel - { - AddPhonePanel(String id, IModel<PhoneNumber> phone) - { - super(id, phone); - add(new Label("areacode", new PropertyModel(phone, "areacode"))); - add(new Label("prefix", new PropertyModel(phone, "prefix"))); - add(new Label("suffix", new PropertyModel(phone, "suffix"))); - } - } - private static class QueuePhonePanel extends AbstractPhonePanel - { - public QueuePhonePanel(String id, IModel<PhoneNumber> phone) - { - super(id, phone); - queue(new Label("areacode", new PropertyModel(phone, "areacode"))); - queue(new Label("prefix", new PropertyModel(phone, "prefix"))); - queue(new Label("suffix", new PropertyModel(phone, "suffix"))); - } - } - - private static abstract class AbstractAddressPanel extends TestPanel - { - AbstractAddressPanel(String id, IModel<Address> addr) - { - super(id); - setPanelMarkup("<wicket:panel><span wicket:id='street'></span><br/><span wicket:id='city'></span>, <span wicket:id='state'></span> <span wicket:id='zipcode'></span></wicket:panel>"); - } - } - - private static class AddAddressPanel extends AbstractAddressPanel - { - AddAddressPanel(String id, IModel<Address> addr) - { - super(id, addr); - add(new Label("street", new PropertyModel(addr, "street"))); - add(new Label("city", new PropertyModel(addr, "city"))); - add(new Label("state", new PropertyModel(addr, "state"))); - add(new Label("zipcode", new PropertyModel(addr, "zipcode"))); - } - } - private class QueueAddressPanel extends AbstractAddressPanel - { - public QueueAddressPanel(String id, IModel<Address> addr) - { - super(id, addr); - queue(new Label("street", new PropertyModel(addr, "street"))); - queue(new Label("city", new PropertyModel(addr, "city"))); - queue(new Label("sate", new PropertyModel(addr, "state"))); - queue(new Label("zipcode", new PropertyModel(addr, "zipcode"))); - } - } - - static class AbstractContactsPage extends TestPage - { - AbstractContactsPage() - { - // @formatter:off - setPageMarkup( - " <div wicket:id='contacts'>" - + " <span wicket:id='first'></span>" - + " <span wicket:id='last'></span>" - + " <div wicket:id='addr'></div>" - + " <div wicket:id='work'></div>" - + " <div wicket:id='cell'></div>" - + "</div>"); - // @formatter:on - - } - } - - public static class AddContactsPage extends AbstractContactsPage - { - public AddContactsPage() - { - add(new RefreshingView<Contact>("contacts") - { - @Override - protected Iterator<IModel<Contact>> getItemModels() - { - return new ModelIteratorAdapter<Contact>(store.contacts.values()) - { - @Override - protected IModel<Contact> model(Contact object) - { - return new ContactModel(object); - } - }; - } - - @Override - protected void populateItem(Item<Contact> item) - { - IModel<Contact> model = item.getModel(); - item.add(new Label("first", new PropertyModel(model, "first"))); - item.add(new Label("last", new PropertyModel(model, "first"))); - item.add(new AddAddressPanel("addr", new PropertyModel<Address>(model, "address"))); - item.add(new AddPhonePanel("work", new PropertyModel<PhoneNumber>(model, "work"))); - item.add(new AddPhonePanel("cell", new PropertyModel<PhoneNumber>(model, "cell"))); - } - }); - - } - } - - public static class QueueContactsPage extends AbstractContactsPage - { - public QueueContactsPage() - { - queue(new RefreshingView<Contact>("contacts") - { - @Override - protected Iterator<IModel<Contact>> getItemModels() - { - return new ModelIteratorAdapter<Contact>(store.contacts.values()) - { - @Override - protected IModel<Contact> model(Contact object) - { - return new ContactModel(object); - } - }; - } - - @Override - protected void populateItem(Item<Contact> item) - { - IModel<Contact> model = item.getModel(); - item.queue(new Label("first", new PropertyModel(model, "first"))); - item.queue(new Label("last", new PropertyModel(model, "first"))); - item.queue(new AddAddressPanel("addr", new PropertyModel<Address>(model, "address"))); - item.queue(new AddPhonePanel("work", new PropertyModel<PhoneNumber>(model, "work"))); - item.queue(new AddPhonePanel("cell", new PropertyModel<PhoneNumber>(model, "cell"))); - } - }); - - } - } - - private static class TestPage extends WebPage implements IMarkupResourceStreamProvider - { - private String markup; - - TestPage() - { - } - - public TestPage(String markup) - { - this.markup = markup; - } - - String getPageMarkup() - { - return markup; - } - - void setPageMarkup(String markup) - { - this.markup = markup; - } - - @Override - public IResourceStream getMarkupResourceStream(MarkupContainer container, - Class<?> containerClass) - { - return new StringResourceStream(getPageMarkup()); - } - - } - - private static class TestPanel extends Panel implements IMarkupResourceStreamProvider - { - - private String markup; - - TestPanel(String id) - { - super(id); - } - - void setPanelMarkup(String markup) - { - this.markup = markup; - } - - String getPanelMarkup() - { - return markup; - } - - @Override - public IResourceStream getMarkupResourceStream(MarkupContainer container, - Class<?> containerClass) - { - return new StringResourceStream(getPanelMarkup()); - } - } -} 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 deleted file mode 100644 index e3f90b4..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/ComponentQueueingTest.java +++ /dev/null @@ -1,1135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.queueing; - -import static org.apache.wicket.queueing.WicketMatchers.hasPath; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -import java.util.ArrayList; - -import org.apache.wicket.Component; -import org.apache.wicket.MarkupContainer; -import org.apache.wicket.WicketRuntimeException; -import org.apache.wicket.markup.IMarkupResourceStreamProvider; -import org.apache.wicket.markup.html.TransparentWebMarkupContainer; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.border.Border; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.internal.Enclosure; -import org.apache.wicket.markup.html.link.Link; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.Model; -import org.apache.wicket.queueing.bodyisachild.BodyIsAChildPage; -import org.apache.wicket.queueing.bodyisachild.LoginPanel; -import org.apache.wicket.queueing.nestedborders.InnerBorder; -import org.apache.wicket.queueing.nestedborders.OuterBorder; -import org.apache.wicket.queueing.nestedpanels.InnerPanel; -import org.apache.wicket.queueing.nestedpanels.OuterPanel; -import org.apache.wicket.util.resource.IResourceStream; -import org.apache.wicket.util.resource.StringResourceStream; -import org.apache.wicket.util.tester.FormTester; -import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.jupiter.api.Test; - -class ComponentQueueingTest extends WicketTestCase -{ - /** {@code [a,b,c] -> [a[b[c]]] } */ - @Test - void dequeue1() - { - 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(); - - p.queue(b, c, a); - assertThat(p, hasPath(a, b, c)); - tester.startPage(p); - } - - /** - * https://issues.apache.org/jira/browse/WICKET-6361 - */ - @Test - 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 - void dequeue2() - { - 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(); - - p.queue(a); - a.queue(b, c); - - tester.startPage(p); - - assertThat(p, hasPath(a, b, c)); - } - - /** {@code [a[b[c]] -> [a[b[c]]] } */ - @Test - void dequeue3() - { - 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(); - - p.queue(a); - a.queue(b); - b.queue(c); - - tester.startPage(p); - - assertThat(p, hasPath(a, b, c)); - } - - /** {@code [a[b],c] -> [a[b[c]]] } */ - @Test - void dequeue4() - { - 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(); - - p.queue(a, c); - a.queue(b); - - tester.startPage(p); - - assertThat(p, hasPath(a, b, c)); - } - - /** {@code [a(b)],c] -> [a[b[c]]] } */ - @Test - void dequeue5() - { - 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(); - p.queue(a, c); - a.add(b); - - tester.startPage(p); - - assertThat(p, hasPath(a, b, c)); - } - - /** {@code [a,b,c] -> [a[b,c]] } */ - @Test - void dequeue6() - { - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><p wicket:id='b'></p><p wicket:id='c'></p></p>"); - MarkupContainer a = new A(), b = new B(), c = new C(); - - p.queue(a, b, c); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, b))); - assertThat(p, hasPath(new Path(a, c))); - } - - /** - * {a[b{e}[d,f{g}]],c} -> [a[b[c,d[e],f[g]]]] - */ - @Test - void dequeue7() - { - TestPage p = new TestPage(); - - // @formatter:off - p.setPageMarkup( - " <p wicket:id='a'>" - + " <p wicket:id='b'>" - + " <p wicket:id='c'></p>" - + " <p wicket:id='d'>" - + " <p wicket:id='e'></p>" - + " </p>" - + " <p wicket:id='f'>" - + " <p wicket:id='g'></p>" - + " </p>" - + " </p>" - + "</p>"); - // @formatter:on - - MarkupContainer a = new A(), b = new B(), c = new C(), d = new D(), e = new E(), f = new F(), g = new G(); - - a.add(b); - b.queue(e); - p.queue(a, c); - b.add(d); - f.queue(g); - b.add(f); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, b, c))); - assertThat(p, hasPath(new Path(a, b, d, e))); - assertThat(p, hasPath(new Path(a, b, f, g))); - } - - - /** {@code [a,c[b]] ->| [a[b[c]]] } */ - @Test - void dequeueError1() - { - 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(); - - p.queue(b, c); - c.queue(a); - - try - { - tester.startPage(p); - fail(); - } - catch (WicketRuntimeException e) - { - // expected - } - } - - /** {@code [a,q[r,s]] - > [a[q[r[s]]]] } */ - @Test - void panel1() - { - MarkupContainer a = new A(), r = new R(), s = new S(); - - TestPanel q = new TestPanel("q"); - q.setPanelMarkup("<wicket:panel><p wicket:id='r'><p wicket:id='s'></p></p></wicket:panel>"); - q.queue(r, s); - - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><p wicket:id='q'></p></p>"); - - p.queue(a, q); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, q, r, s))); - } - - /** panel has leading markup */ - @Test - void panel2() - { - MarkupContainer r = new R(); - - TestPanel q = new TestPanel("q"); - q.setPanelMarkup("<html><body><wicket:panel><p wicket:id='r'></p></wicket:panel></body></html>"); - q.queue(r); - - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='q'></p>"); - p.queue(q); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(q, r))); - } - - /** panel with a static header section */ - @Test - void panel3() - { - MarkupContainer r = new R(); - - TestPanel q = new TestPanel("q"); - q.setPanelMarkup("<html><head><wicket:head><meta/></wicket:head></head>" - + "<body><wicket:panel><p wicket:id='r'></p></wicket:panel></body></html>"); - q.queue(r); - - TestPage p = new TestPage(); - p.setPageMarkup("<html><head></head><body><p wicket:id='q'></p></body></html>"); - p.queue(q); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(q, r))); - tester.assertContains("<meta/>"); // contributed by <wicket:head> - } - - /** - * test with inner panels - */ - @Test - void nestedPanels() - { - MarkupContainer r = new R(), s = new S(); - - Panel innerPanel = new InnerPanel("inner"); - innerPanel.queue(s); - - Panel outerPanel = new OuterPanel("outer"); - - outerPanel.queue(r, innerPanel); - - TestPage p = new TestPage(); - p.setPageMarkup("<html><head></head><body><p wicket:id='outer'></p></body></html>"); - p.queue(outerPanel); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(outerPanel, r))); - assertThat(p, hasPath(new Path(outerPanel, innerPanel, s))); - tester.assertContains("<meta/>"); // contributed by <wicket:head> in outer - tester.assertContains("<meta2/>"); // contributed by <wicket:head> in inner - } - - @Test - void repeater1() - { - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='lv'><p wicket:id='b'><p wicket:id='c'></p></p></p>"); - - LV l = new LV(3) - { - @Override - protected void populateItem(ListItem<Integer> item) - { - item.queue(new B(), new C()); - } - }; - - p.queue(l); - - tester.startPage(p); - - assertEquals(3, l.size()); - for (Component item : l) - { - assertThat(p, hasPath(new Path(l, item, new B(), new C()))); - } - } - - /** repeater */ - @Test - void repeater2() - { - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><p wicket:id='lv'><p wicket:id='b'><p wicket:id='c'></p></p></p></p>"); - - MarkupContainer a = new A(); - LV l = new LV(3) - { - @Override - protected void populateItem(ListItem<Integer> item) - { - item.queue(new B(), new C()); - } - }; - - p.queue(a, l); - - tester.startPage(p); - - assertEquals(3, l.size()); - for (Component item : l) - { - assertThat(p, hasPath(new Path(a, l, item, new B(), new C()))); - } - } - - /** repeater with a panel inside */ - @Test - void repeater3() - { - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><p wicket:id='lv'><p wicket:id='b'><p wicket:id='q'></p></p></p></p>"); - - MarkupContainer a = new A(); - LV l = new LV(3) - { - @Override - protected void populateItem(ListItem<Integer> item) - { - TestPanel q = new TestPanel("q"); - q.setPanelMarkup("<wicket:panel><p wicket:id='r'><p wicket:id='s'></p></p></wicket:panel>"); - q.queue(new R(), new S()); - - item.queue(q, new B()); - } - }; - - p.queue(a, l); - - tester.startPage(p); - - assertEquals(3, l.size()); - for (Component item : l) - { - assertThat(p, hasPath(new Path(a, l, item, new B()).add("q").add(new R(), new S()))); - } - } - - /** dequeue, then rerender the page instance after a callback is executed */ - @Test - void callback() - { - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><a wicket:id='l'><p wicket:id='b'></p></a></p>"); - MarkupContainer a = new A(), b = new B(); - L l = new L(); - p.queue(a, b, l); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, l, b))); - assertEquals(false, l.isClicked()); - - tester.clickLink(l); - - assertEquals(true, l.isClicked()); - } - - - /** queuing two components with the same id */ - @Test - void queueIdCollission() - { - try - { - new A().queue(new B(), new B()); - fail("Should not be able to queue two components with the same id under the same parent"); - } - catch (WicketRuntimeException e) - { - // expected - } - } - - - @Test - void autos1() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>"); - A a = new A(); - B b = new B(); - p.queue(a, b); - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - assertTrue(b.getParent() instanceof Enclosure); - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - @Test - void autos2() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>"); - A a = new A(); - B b = new B(); - p.add(a, b); - tester.startPage(p); - - assertTrue(a.getParent() instanceof TestPage); - assertTrue(b.getParent() instanceof TestPage); - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - @Test - void autos3() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>"); - A a = new A(); - B b = new B(); - p.queue(b); - p.add(a); - tester.startPage(p); - - assertTrue(a.getParent() instanceof TestPage); - assertTrue(b.getParent() instanceof Enclosure); - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - @Test - void autos4() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>"); - A a = new A(); - B b = new B(); - p.add(b); - p.queue(a); - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - assertTrue(b.getParent() instanceof TestPage); - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - @Test - void autos5() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>"); - A a = new A(); - B b = new B(); - p.queue(a); - p.add(b); - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - assertTrue(b.getParent() instanceof TestPage); - - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - /** - * Test InlineEnclosure - */ - @Test - void autos6() - { - TestPage p = new TestPage(); - p.setPageMarkup("<div wicket:enclosure='a'><div wicket:id='a'></div><div wicket:id='b'></div></div>"); - A a = new A(); - B b = new B(); - p.queue(a, b); - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - assertTrue(b.getParent() instanceof Enclosure); - - // A is visible, enclosure renders - - assertEquals( - "<div wicket:enclosure=\"a\" id=\"wicket__InlineEnclosure_20793898271\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></div>", - tester.getLastResponseAsString()); - - // A is not visible, inline enclosure render only itself (the placeholder tag) - - a.setVisible(false); - tester.startPage(p); - assertEquals("<div id=\"wicket__InlineEnclosure_20793898271\" hidden=\"\" data-wicket-placeholder=\"\"></div>", tester.getLastResponseAsString()); - } - - /** - * Test empty child attribute - */ - @Test - void autos7() - { - TestPage p = new TestPage(); - p.setPageMarkup("<wicket:enclosure child=''><div wicket:id='a'></div></wicket:enclosure>"); - A a = new A(); - - p.queue(a); - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - - - // A is visible, enclosure renders - - assertEquals( - "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div></wicket:enclosure>", - tester.getLastResponseAsString()); - - // A is not visible, enclosure does not render - - a.setVisible(false); - tester.startPage(p); - assertEquals("", tester.getLastResponseAsString()); - } - - /** - * Test autocomponent inside not-queue region - */ - @Test - void autosInsideNotQueueRegion() - { - TestPage p = new TestPage(); - p.setPageMarkup("<div wicket:id='outerContainer'><wicket:enclosure><div wicket:id='a'></div></wicket:enclosure></div>"); - Label a = new Label("a", "a"); - WebMarkupContainer outer; - p.add(outer = new WebMarkupContainer("outerContainer")); - outer.queue(a); - - tester.startPage(p); - - assertTrue(a.getParent() instanceof Enclosure); - } - - @Test - void border1() - { - MarkupContainer a = new A(), b = new B(), r = new R(), s = new S(); - - TestBorder border = new TestBorder("border"); - border.setBorderMarkup("<wicket:border><b1 wicket:id='r'><b2 wicket:id='s'>" + - "<wicket:body/></b2></b1></wicket:border>"); - border.queueToBorder(r, s); - - TestPage p = new TestPage(); - p.setPageMarkup("<out1 wicket:id='a'><p wicket:id='border'><in1 wicket:id='b'></in1></p></out1>"); - - p.queue(a, border, b); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, border, r, s, border.getBodyContainer(), b))); - } - - @Test - void queueBorderBody() throws Exception - { - - TestBorder border = new TestBorder("border"); - border.setBorderMarkup("<wicket:border><wicket:body/></wicket:border>"); - - TestPage p = new TestPage(); - p.setPageMarkup("<div wicket:id=\"border\"><span wicket:id=\"label\"></span></div>"); - - p.add(border); - border.queue(new Label("label", "test")); - - tester.startPage(p); - } - - @Test - void border_nested() - { - MarkupContainer a = new A(), b = new B(), c= new C(), d = new D(), r = new R(), s = new S(); - - Border outerBorder = new OuterBorder("outerBorder"); - - Border innerBorder = new InnerBorder("innerBorder"); - - outerBorder.queueToBorder(r, innerBorder); - - innerBorder.queueToBorder(c, d); - - outerBorder.queueToBorder(s); - - - TestPage p = new TestPage(); - p.setPageMarkup("<p wicket:id='a'><p wicket:id='outerBorder'><p wicket:id='b'></p></p></p>"); - - p.queue(b, outerBorder, a); - - tester.startPage(p); - - assertThat(p, hasPath(new Path(a, outerBorder, r, innerBorder, c, d, innerBorder.getBodyContainer(), s))); - assertThat(p, hasPath(new Path(a, outerBorder, r, outerBorder.getBodyContainer(), b))); - } - - @Test - void fragment1() { - MarkupContainer a = new A(), b = new B(), r = new R(), s = new S(); - - TestPage page = new TestPage(); - page.setPageMarkup("<a wicket:id='a'></a><f wicket:id='fragment'></f><b wicket:id='b'></b>" - + "<wicket:fragment wicket:id='f'><r wicket:id='r'></r><s wicket:id='s'></s></wicket:fragment>"); - - Fragment fragment = new Fragment("fragment", "f", page); - - fragment.queue(r, s); - page.queue(a, b, fragment); - - assertThat(page, hasPath(new Path(a))); - assertThat(page, hasPath(new Path(b))); - assertThat(page, hasPath(new Path(fragment, r))); - assertThat(page, hasPath(new Path(fragment, s))); - } - - @Test - void fragment_doesNotDequeueAcrossRegion() - { - MarkupContainer a = new A(); - - TestPage page = new TestPage(); - page.setPageMarkup("<f wicket:id='fragment'></f><wicket:fragment wicket:id='f'><a wicket:id='a'></a></wicket:fragment>"); - - Fragment fragment = new Fragment("fragment", "f", page); - - page.queue(a, fragment); - - assertThat(page, hasPath(new Path(fragment))); - assertNull(a.getParent()); - } - - - @Test - void containerTag1() - { - MarkupContainer a = new A(), b = new B(); - - TestPage page = new TestPage(); - page.setPageMarkup("<wicket:container wicket:id='a'><b wicket:id='b'></b></wicket:container>"); - - page.queue(a, b); - - assertThat(page, hasPath(new Path(a, b))); - } - - @Test - void queueInsideHeader() - { - TestPage page = new TestPage(); - page.setPageMarkup("<html>" - +"<head><title wicket:id='title'></title></head>" - + "<body><div>" - + "Hello!" - + "</div></body>" - + "</html>"); - - page.queue(new Label("title")); - - tester.startPage(page); - - tester.assertContains("title"); - } - - @Test - void queueInsideAutoLink() - { - TestPage page = new TestPage(); - page.setPageMarkup("<wicket:link>" - + "<a href='test.html'>" - + "<wicket:container wicket:id='test'>test</wicket:container>" - + "</a></wicket:link>"); - - page.queue(new WebMarkupContainer("test")); - - tester.startPage(page); - } - - @Test - void queueInsideLabelComponent() - { - TestPage page = new TestPage(); - page.setPageMarkup("<label wicket:for='input'>" - + "label:" - + "<input wicket:id='input'/>" - + "</label>"); - - page.queue(new TextField<>("input", Model.of("test"))); - - tester.startPage(page); - } - - @Test - void queueInsideTransparentContainer() throws Exception - { - TestPage page = new TestPage(); - page.setPageMarkup("<div wicket:id='transparentContainer'>" - + " <div wicket:id='container'>" - + " <div wicket:id='child'>" - + " </div>" - + " </div>" - + "</div>"); - - page.add(new TransparentWebMarkupContainer("transparentContainer")); - page.add(new WebMarkupContainer("container")); - page.queue(new WebMarkupContainer("child")); - - tester.startPage(page); - } - - @Test - void queueNestedEnclosure() - { - TestPage page = new TestPage(); - page.setPageMarkup( "<div wicket:enclosure='outer'>" + - "<div wicket:id='outer'>" + - " <div wicket:enclosure='middle'>" + - " <div wicket:enclosure='inner'>" + - " <div wicket:id='inner'>inner</div>" + - " </div>" + - " <div wicket:id='middle'>middle</div>" + - " </div>" + - " outer" + - "</div>" + - "</div>"); - - WebMarkupContainer container = new WebMarkupContainer("outer"); - container.add(new WebMarkupContainer("middle")); - container.add(new WebMarkupContainer("inner")); - - page.add(container); - - tester.startPage(page); - } - - /** - * https://issues.apache.org/jira/browse/WICKET-6088 - */ - @Test - void queueComponentInsideWcAndEnclosure() - { - TestPage page = new TestPage(); - page.setPageMarkup(" <div wicket:id=\"container\">\n" + - " <div wicket:enclosure=\"child\">\n" + - " <p wicket:id=\"child\">1</p>\n" + - " <a wicket:id=\"child2\">2</a>\n" + - " </div>\n" + - " </div>"); - - WebMarkupContainer container = new WebMarkupContainer("container"); - - container.queue(new Label("child") - { - @Override - protected void onInitialize() - { - super.onInitialize(); - - setDefaultModel(Model.of("test")); - } - }); - - container.queue(new WebMarkupContainer("child2").setVisible(false)); - - page.queue(container); - - tester.startPage(page); - } - @Test - void queueComponentInsideBorderAndEnclosure() - { - TestPage page = new TestPage(); - page.setPageMarkup(" <div wicket:id=\"panel\"></div>"); - - TestPanel panel = new TestPanel("panel"); - panel.setPanelMarkup("<wicket:panel>\n" - + "<div wicket:id=\"border\">\n" + - " <div wicket:enclosure=\"child\">\n" + - " <p wicket:id=\"child\">1</p>\n" + - " </div>\n" + - " </div>\n" + - "</wicket:panel>"); - - TestBorder border = new TestBorder("border"); - border.setBorderMarkup("<wicket:border><wicket:body/></wicket:border>"); - - panel.add(border); - page.add(panel); - border.add(new Label("child")); - - tester.startPage(page); - } - - /** - * https://issues.apache.org/jira/browse/WICKET-6036 - */ - @Test - void nestedTags() - { - IncorrectCloseTagPanel p = new IncorrectCloseTagPanel("test"); - tester.startComponentInPage(p); - } - - /** - * https://issues.apache.org/jira/browse/WICKET-6077 - */ - @Test - void bodyIsAChild() { - tester.startPage(BodyIsAChildPage.class); - - tester.assertRenderedPage(BodyIsAChildPage.class); - - String username = "USER"; - String password = "PASSWD"; - - FormTester formTester = tester.newFormTester("wmc:login:loginForm"); - formTester.setValue("usernameFormGroup:usernameFormGroup_body:username", username); - formTester.setValue("passwordFormGroup:passwordFormGroup_body:password", password); - formTester.submit(); - - LoginPanel loginPanel = (LoginPanel) tester.getComponentFromLastRenderedPage("wmc:login"); - assertEquals(username, loginPanel.pojo.username); - assertEquals(password, loginPanel.pojo.password); - } - - private static class A extends WebMarkupContainer - { - A() - { - super("a"); - } - } - - private static class B extends WebMarkupContainer - { - B() - { - super("b"); - } - } - - private static class C extends WebMarkupContainer - { - C() - { - super("c"); - } - } - - private static class D extends WebMarkupContainer - { - D() - { - super("d"); - } - } - - private static class E extends WebMarkupContainer - { - E() - { - super("e"); - } - } - - private static class F extends WebMarkupContainer - { - F() - { - super("f"); - } - } - private static class G extends WebMarkupContainer - { - G() - { - super("g"); - } - } - - private static class R extends WebMarkupContainer - { - R() - { - super("r"); - } - } - - private static class S extends WebMarkupContainer - { - S() - { - super("s"); - } - } - - private static abstract class LV extends ListView<Integer> - { - LV(int size) - { - super("lv"); - ArrayList<Integer> values = new ArrayList<>(); - for (int i = 0; i < size; i++) - values.add(i); - setModel(new Model<>(values)); - } - } - - private static class L extends Link<Void> - { - private boolean clicked = false; - - L() - { - super("l"); - } - - @Override - public void onClick() - { - clicked = true; - } - - boolean isClicked() - { - return clicked; - } - } - - - private static class TestPage extends WebPage implements IMarkupResourceStreamProvider - { - private String markup; - - TestPage() - { - } - - public TestPage(String markup) - { - this.markup = markup; - } - - String getPageMarkup() - { - return markup; - } - - void setPageMarkup(String markup) - { - this.markup = markup; - } - - @Override - public IResourceStream getMarkupResourceStream(MarkupContainer container, - Class<?> containerClass) - { - return new StringResourceStream(getPageMarkup()); - } - - } - - private static class TestPanel extends Panel implements IMarkupResourceStreamProvider - { - private String markup; - - TestPanel(String id) - { - super(id); - } - - void setPanelMarkup(String markup) - { - this.markup = markup; - } - - String getPanelMarkup() - { - return markup; - } - - @Override - public IResourceStream getMarkupResourceStream(MarkupContainer container, - Class<?> containerClass) - { - return new StringResourceStream(getPanelMarkup()); - } - } - - private static class TestBorder extends Border implements IMarkupResourceStreamProvider - { - private String markup; - - TestBorder(String id) - { - super(id); - } - - void setBorderMarkup(String markup) - { - this.markup = markup; - } - - String getBorderMarkup() - { - return markup; - } - - @Override - public IResourceStream getMarkupResourceStream(MarkupContainer container, - Class<?> containerClass) - { - return new StringResourceStream(getBorderMarkup()); - } - } -} diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/SubPage.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/SubPage.java index 6580fb5c..ac48e19 100644 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/SubPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/SubPage.java @@ -28,6 +28,6 @@ public class SubPage extends BasePage { super(parameters); - queue(new Label("version", getApplication().getFrameworkSettings().getVersion())); + add(new Label("version", getApplication().getFrameworkSettings().getVersion())); } } diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TransparentContainerQueuePage.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TransparentContainerQueuePage.java index ba2c2d8..2f8d617 100644 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TransparentContainerQueuePage.java +++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TransparentContainerQueuePage.java @@ -26,7 +26,7 @@ public class TransparentContainerQueuePage extends WebPage public TransparentContainerQueuePage(PageParameters parameters) { super(parameters); - queue(new Label("queuedComponent", "Queued label.")); + add(new Label("queuedComponent", "Queued label.")); } } diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalDialogPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalDialogPage.java index 665b100..7df2ae0 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalDialogPage.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalDialogPage.java @@ -57,22 +57,24 @@ public class ModalDialogPage extends BasePage public ModalDialogPage() { - queue(new RadioGroup("stacked", new PropertyModel<>(this, "stacked")) - .setRenderBodyOnly(false).add(new AjaxFormChoiceComponentUpdatingBehavior() - { + RadioGroup radioGroup = new RadioGroup("stacked", new PropertyModel<>(this, "stacked")); + radioGroup + .setRenderBodyOnly(false) + .add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { } - })); + }); + add(radioGroup); - queue(new Radio<Boolean>("yes", Model.of(true))); - queue(new Radio<Boolean>("no", Model.of(false))); + radioGroup.add(new Radio<Boolean>("yes", Model.of(true))); + radioGroup.add(new Radio<Boolean>("no", Model.of(false))); - queue(new ModalFragment("start")); + add(new ModalFragment("start")); stackedDialogs = new AjaxListPanel("stackedDialogs"); - queue(stackedDialogs); + add(stackedDialogs); } @Override @@ -94,15 +96,15 @@ public class ModalDialogPage extends BasePage super(id, "fragment", ModalDialogPage.this); Form<Void> form = new Form<Void>("form"); - queue(form); + add(form); nestedDialog = new ModalDialog("nestedDialog"); nestedDialog.add(new DefaultTheme()); nestedDialog.trapFocus(); nestedDialog.closeOnEscape(); - queue(nestedDialog); + form.add(nestedDialog); - queue(new AjaxLink<Void>("ajaxOpenDialog") + form.add(new AjaxLink<Void>("ajaxOpenDialog") { @Override public void onClick(AjaxRequestTarget target) @@ -111,7 +113,7 @@ public class ModalDialogPage extends BasePage } }); - queue(new Link<Void>("openDialog") + form.add(new Link<Void>("openDialog") { @Override public void onClick() @@ -120,7 +122,7 @@ public class ModalDialogPage extends BasePage } }); - queue(new TextField("text").add(new AjaxEventBehavior("keydown") + form.add(new TextField("text").add(new AjaxEventBehavior("keydown") { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) @@ -144,7 +146,7 @@ public class ModalDialogPage extends BasePage } })); - queue(new WebMarkupContainer("closing") + WebMarkupContainer closing = new WebMarkupContainer("closing") { @Override protected void onConfigure() @@ -153,9 +155,10 @@ public class ModalDialogPage extends BasePage setVisible(findParent(ModalDialog.class) != null); } - }); + }; + form.add(closing); - queue(new Link<Void>("close") + closing.add(new Link<Void>("close") { @Override public void onClick() @@ -166,9 +169,9 @@ public class ModalDialogPage extends BasePage final MultiLineLabel lorem = new MultiLineLabel("lorem", ""); lorem.setOutputMarkupId(true); - queue(lorem); + form.add(lorem); - queue(new AjaxLink<Void>("ipsum") { + form.add(new AjaxLink<Void>("ipsum") { @Override public void onClick(AjaxRequestTarget target) {