You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Gerolf Seitz <ge...@gmail.com> on 2007/12/01 15:06:21 UTC

BaseWicketTester#clickLink does not "simulate" ajax request

hi,
it seems like BaseWicketTester#clickLink does not generate an ajax request.
excerpt:

if (linkComponent instanceof AjaxLink)
        {
            // If it's not ajax we fail
[0]        if (isAjax == false)
            {
                fail("Link " + path + "is an AjaxLink and will " +
                    "not be invoked when AJAX (javascript) is disabled.");
            }

            AjaxLink link = (AjaxLink)linkComponent;

            setupRequestAndResponse();

[1]         // getServletRequest().addHeader("Wicket-Ajax", "Yes");

[2]        RequestCycle requestCycle = createRequestCycle();
            if (requestCycle.getRequest() instanceof WebRequest &&
                !((WebRequest)requestCycle.getRequest()).isAjax())
            {
                fail("this is no ajax request");
            }


[0] only uses the parameter for the check, not the actual request

if [1] is uncommented, several other tests fail, due to assuming that there
is an ajax request, when actually there is none

[2] checks whether the current WebRequest is an ajax request. with [1] being
commented, the test fails with "this is no ajax request".

note: [1] and [2] were added by me and cannot be found in the code in trunk



either i'm missing something, or a lot of tests involving ajax are seriously
broken.
in any case, this should be clarified before releasing RC2.

any comments?

  Gerolf

Re: BaseWicketTester#clickLink does not "simulate" ajax request

Posted by Frank Bille <fr...@apache.org>.
I think you're right on this. Just remember to set the Wicket-Ajax header on
all the different ajax requests (links (both ajax, ajaxfallback and
ajaxsubmit), ajaxbevahior execution).

This might break some users tests, but IMO it's worth it because those tests
might have been wrong anyway.

+1

Frank


On Dec 1, 2007 3:55 PM, Gerolf Seitz <ge...@gmail.com> wrote:

> another indication that there is something wrong is that
> AjaxRequestTargetTest#testHeaderContribution3
> expects that the wicket:id of the stylesheetreference is rendered, whereas
> according to
> Component#renderComponentTag, which sets stripWicketTags (for the
> methodcall
> tag.writeOutput) to true for ajaxrequests,
> wicket: attributes are not rendered.
>
>  Gerolf
>
>
> On Dec 1, 2007 3:06 PM, Gerolf Seitz <ge...@gmail.com> wrote:
>
> > hi,
> > it seems like BaseWicketTester#clickLink does not generate an ajax
> > request.
> > excerpt:
> >
> > if (linkComponent instanceof AjaxLink)
> >         {
> >             // If it's not ajax we fail
> > [0]        if (isAjax == false)
> >             {
> >                 fail("Link " + path + "is an AjaxLink and will " +
> >                     "not be invoked when AJAX (javascript) is
> disabled.");
> >             }
> >
> >             AjaxLink link = (AjaxLink)linkComponent;
> >
> >             setupRequestAndResponse();
> >
> > [1]         // getServletRequest().addHeader("Wicket-Ajax", "Yes");
> >
> > [2]        RequestCycle requestCycle = createRequestCycle();
> >             if ( requestCycle.getRequest() instanceof WebRequest &&
> >                 !((WebRequest)requestCycle.getRequest()).isAjax())
> >             {
> >                 fail("this is no ajax request");
> >             }
> >
> >
> > [0] only uses the parameter for the check, not the actual request
> >
> > if [1] is uncommented, several other tests fail, due to assuming that
> > there is an ajax request, when actually there is none
> >
> > [2] checks whether the current WebRequest is an ajax request. with [1]
> > being commented, the test fails with "this is no ajax request".
> >
> > note: [1] and [2] were added by me and cannot be found in the code in
> > trunk
> >
> >
> >
> > either i'm missing something, or a lot of tests involving ajax are
> > seriously broken.
> > in any case, this should be clarified before releasing RC2.
> >
> > any comments?
> >
> >   Gerolf
> >
>

Re: BaseWicketTester#clickLink does not "simulate" ajax request

Posted by Gerolf Seitz <ge...@gmail.com>.
another indication that there is something wrong is that
AjaxRequestTargetTest#testHeaderContribution3
expects that the wicket:id of the stylesheetreference is rendered, whereas
according to
Component#renderComponentTag, which sets stripWicketTags (for the methodcall
tag.writeOutput) to true for ajaxrequests,
wicket: attributes are not rendered.

  Gerolf


On Dec 1, 2007 3:06 PM, Gerolf Seitz <ge...@gmail.com> wrote:

> hi,
> it seems like BaseWicketTester#clickLink does not generate an ajax
> request.
> excerpt:
>
> if (linkComponent instanceof AjaxLink)
>         {
>             // If it's not ajax we fail
> [0]        if (isAjax == false)
>             {
>                 fail("Link " + path + "is an AjaxLink and will " +
>                     "not be invoked when AJAX (javascript) is disabled.");
>             }
>
>             AjaxLink link = (AjaxLink)linkComponent;
>
>             setupRequestAndResponse();
>
> [1]         // getServletRequest().addHeader("Wicket-Ajax", "Yes");
>
> [2]        RequestCycle requestCycle = createRequestCycle();
>             if ( requestCycle.getRequest() instanceof WebRequest &&
>                 !((WebRequest)requestCycle.getRequest()).isAjax())
>             {
>                 fail("this is no ajax request");
>             }
>
>
> [0] only uses the parameter for the check, not the actual request
>
> if [1] is uncommented, several other tests fail, due to assuming that
> there is an ajax request, when actually there is none
>
> [2] checks whether the current WebRequest is an ajax request. with [1]
> being commented, the test fails with "this is no ajax request".
>
> note: [1] and [2] were added by me and cannot be found in the code in
> trunk
>
>
>
> either i'm missing something, or a lot of tests involving ajax are
> seriously broken.
> in any case, this should be clarified before releasing RC2.
>
> any comments?
>
>   Gerolf
>

Re: BaseWicketTester#clickLink does not "simulate" ajax request

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Sat, 01 Dec 2007, Gerolf Seitz wrote:
> it seems like BaseWicketTester#clickLink does not generate an ajax request.
...
> any comments?

I've fired Ajax links by
WicketTester.executeAjaxEvent("onclick") and find it makes
sense. Because cannot there be ajax behaviours triggered on
other events as well (onmousedown, onmouseup)?

I might be wrong as I don't know much about Javascript
events but giving onclick a special handling seems strange
to me. I've always thought of clickLink as a plain click that
does not invoke any Javascript. So that would give the same
behavior as clicking with Javascript disabled, and you would
have to fire all Ajax behaviours separately.

Best wishes,
Timo