Hi,

On Wed, May 6, 2015 at 12:25 PM, <dasho...@apache.org> wrote:

> Repository: wicket
> Updated Branches:
>   refs/heads/wicket-6.x e4c1d939f -> 0199bfab7
>
>
> Added WicketTester support for IAjaxLink
>
> WicketTester didn't click direct IAjaxLink implementations using an
> Ajax request but a normal request. Some components implement
> IAjaxLink directly instead of subclassing AjaxLink or other
> components.
>
> Fixes WICKET-5900
>
>
> Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
> Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0199bfab
> Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0199bfab
> Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0199bfab
>
> Branch: refs/heads/wicket-6.x
> Commit: 0199bfab7cc27e14759d634a1b48f92c9e59a9d2
> Parents: e4c1d93
> Author: Martijn Dashorst <martijn.dasho...@gmail.com>
> Authored: Wed May 6 11:22:55 2015 +0200
> Committer: Martijn Dashorst <martijn.dasho...@gmail.com>
> Committed: Wed May 6 11:25:22 2015 +0200
>
> ----------------------------------------------------------------------
>  .../org/apache/wicket/util/tester/BaseWicketTester.java  | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/wicket/blob/0199bfab/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 2849c3c..8b230b8 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
> @@ -59,6 +59,7 @@ import org.apache.wicket.ajax.AjaxEventBehavior;
>  import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
>  import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
>  import org.apache.wicket.ajax.markup.html.AjaxLink;
> +import org.apache.wicket.ajax.markup.html.IAjaxLink;
>  import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
>  import org.apache.wicket.behavior.AbstractAjaxBehavior;
>  import
> org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler;
> @@ -1881,6 +1882,16 @@ public class BaseWicketTester
>                         submitAjaxFormSubmitBehavior(link,
>
> (AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link,
> "onclick"));
>                 }
> +               // if the link is an IAjaxLink, use it (do check if AJAX
> is expected)
> +               else if (linkComponent instanceof IAjaxLink && isAjax)
>

I see some inconsistencies now:
1) earlier there is a check for AjaxLink that is also IAjaxLink and it has
the same logic
2) it uses fail() in the case when isAjax is false
IMO AjaxPagingNavigationLink should behave the same way. In the browser it
would not act as a **Fallback link
Maybe the code for AjaxLink and IAjaxLink should be merged?!
Additionally we can introduce IFallback marker interface (as you suggested
at dev@) and fail if isAjax is false && isFallback == false.

+               {
> +                       List<AjaxEventBehavior> behaviors =
> WicketTesterHelper.findAjaxEventBehaviors(
> +                               linkComponent, "click");
> +                       for (AjaxEventBehavior behavior : behaviors)
> +                       {
> +                               executeBehavior(behavior);
> +                       }
> +               }
>                 /*
>                  * If the link is a submitlink then we pretend to have
> clicked it
>                  */
>
>

Reply via email to