Updated Branches: refs/heads/wicket-1.5.x 6ba2d80b9 -> 2a4d6c151
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/2a4d6c15 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2a4d6c15 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2a4d6c15 Branch: refs/heads/wicket-1.5.x Commit: 2a4d6c151792d68b5d73fc1a347e7516187d8078 Parents: 6ba2d80 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Tue Feb 21 14:36:45 2012 +0100 Committer: martin-g <[email protected]> Committed: Tue Feb 21 14:42:34 2012 +0100 ---------------------------------------------------------------------- .../wicket/util/tester/BaseWicketTester.java | 33 ++++++++++++++- 1 files changed, 31 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/2a4d6c15/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 5cf67ff..252fea4 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 @@ -43,7 +43,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import junit.framework.AssertionFailedError; - import org.apache.wicket.Application; import org.apache.wicket.Component; import org.apache.wicket.IPageManagerProvider; @@ -1270,12 +1269,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) { @@ -1286,6 +1292,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 @@ -1324,12 +1336,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) { @@ -1340,6 +1359,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 @@ -1522,7 +1547,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);
