You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/02/21 14:36:56 UTC
git commit: WICKET-4424 getComponentFromLastRenderedPage appends
componentInPage id when it shouldn't
Updated Branches:
refs/heads/master 59da20da4 -> 47d4674b5
WICKET-4424 getComponentFromLastRenderedPage appends componentInPage id when it shouldn't
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/47d4674b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/47d4674b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/47d4674b
Branch: refs/heads/master
Commit: 47d4674b5d7ba1badcb488cb4ef2c3bbcf9bc0fe
Parents: 59da20d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Feb 21 14:36:45 2012 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Feb 21 14:36:45 2012 +0100
----------------------------------------------------------------------
.../wicket/util/tester/BaseWicketTester.java | 35 +++++++++++++-
1 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/47d4674b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
index f6e771a..e400de3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
@@ -42,7 +42,6 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import junit.framework.AssertionFailedError;
-
import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.IPageManagerProvider;
@@ -64,8 +63,8 @@ import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.behavior.AbstractAjaxBehavior;
import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.FeedbackCollector;
+import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.ContainerInfo;
import org.apache.wicket.markup.IMarkupFragment;
@@ -1184,12 +1183,19 @@ public class BaseWicketTester
/**
* Process a component. A web page will be automatically created with the markup created in
* {@link #createPageMarkup(String)}.
+ * <p>
+ * <strong>Note</strong>: the instantiated component will have an auto-generated id. To
+ * reach any of its children use their relative path to the component itself. For example
+ * if the started component has a child a Link component with id "link" then after starting
+ * the component you can click it with: <code>tester.clickLink("link")</code>
+ * </p>
*
* @param <C>
* the type of the component
* @param componentClass
* the class of the component to be tested
* @return The component processed
+ * @see #startComponentInPage(org.apache.wicket.Component)
*/
public final <C extends Component> C startComponentInPage(final Class<C> componentClass)
{
@@ -1200,6 +1206,12 @@ public class BaseWicketTester
* Process a component. A web page will be automatically created with the {@code pageMarkup}
* provided. In case pageMarkup is null, the markup will be automatically created with
* {@link #createPageMarkup(String)}.
+ * <p>
+ * <strong>Note</strong>: the instantiated component will have an auto-generated id. To
+ * reach any of its children use their relative path to the component itself. For example
+ * if the started component has a child a Link component with id "link" then after starting
+ * the component you can click it with: <code>tester.clickLink("link")</code>
+ * </p>
*
* @param <C>
* the type of the component
@@ -1239,12 +1251,19 @@ public class BaseWicketTester
/**
* Process a component. A web page will be automatically created with markup created by the
* {@link #createPageMarkup(String)}.
+ * <p>
+ * <strong>Note</strong>: the component id is set by the user. To
+ * reach any of its children use this id + their relative path to the component itself. For example
+ * if the started component has id <em>compId</em> and a Link child component component with id "link"
+ * then after starting the component you can click it with: <code>tester.clickLink("compId:link")</code>
+ * </p>
*
* @param <C>
* the type of the component
* @param component
* the component to be tested
* @return The component processed
+ * @see #startComponentInPage(Class)
*/
public final <C extends Component> C startComponentInPage(final C component)
{
@@ -1255,6 +1274,12 @@ public class BaseWicketTester
* Process a component. A web page will be automatically created with the {@code pageMarkup}
* provided. In case {@code pageMarkup} is null, the markup will be automatically created with
* {@link #createPageMarkup(String)}.
+ * <p>
+ * <strong>Note</strong>: the component id is set by the user. To
+ * reach any of its children use this id + their relative path to the component itself. For example
+ * if the started component has id <em>compId</em> and a Link child component component with id "link"
+ * then after starting the component you can click it with: <code>tester.clickLink("compId:link")</code>
+ * </p>
*
* @param <C>
* the type of the component
@@ -1437,7 +1462,11 @@ public class BaseWicketTester
{
if (componentInPage != null && componentInPage.isInstantiated)
{
- path = componentInPage.component.getId() + ":" + path;
+ String componentIdPageId = componentInPage.component.getId() + ':';
+ if (path.startsWith(componentIdPageId) == false)
+ {
+ path = componentIdPageId + path;
+ }
}
Component component = getLastRenderedPage().get(path);