You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jeffrey Schwartz <je...@gmail.com> on 2011/12/12 01:20:04 UTC

AbstractAjaxBehavior::onRequest never called due to redirect url dropping the callback url

Summary of problem:  AbstractAjaxBehavior::onRequestMethod not called on redirect. 

I am using jQuery UI autocomplete. I cannot get it to work with Wicket 1.5. The issue appears to be that the original request which includes the listener's address is redirected by the server (tried both Glassfish and Apache Tomcat) but the redirect url doesn't include the listener's address parameter.

I know my jQuery UI is installed and working correctly because I created a simple Servlet app and the servlet is receiving the request without redirecting and the request includes the request params as well.

Here's the code I am using on the server:

        add(aab2 = new AbstractAjaxBehavior() {

            // handle the ajax request
            @Override
            public void onRequest() {
                System.out.println("aab2 ajax request received");

//                RequestCycle requestCycle = getComponent().getRequestCycle();
//                Request request = requestCycle.getRequest();
//                IRequestParameters irp = request.getPostParameters();
//                StringValue state = irp.getParameterValue("state");
//                List<String> statesLike = MockDb.getStatesLike(state.toString());
//                requestCycle.scheduleRequestHandlerAfterCurrent(new TextRequestHandler("application/json","UTF-8",convertListToJson(statesLike)));
            }
        });

        add(myScript = new Label("myScript", "var callbackUrl = '" + aab2.getCallbackUrl() + "'"));
        myScript.setEscapeModelStrings(false);

Here's the client side Javascript code:

$('input.jqueryid_state').autocomplete({source: callbackUrl});

My dev environment is Mac OS X Lion & Netbeans 7.0.1 if that matters. I am using Wicket v1.5.1.

When running the code the server log never show the message "aab2 ajax request received" and Safari's Web Inspector dev tool reports the redirect along with the truncated url and the response to that is that Wicket renders the whole page.

Here's what I see in Safari Web Inspector:







As can be seen from the above images the original GET request included the call back url but the redirect does not.

Am I doing something wrong and does any one have a suggestion/idea?

Thanks in advance,
Jeff

Re: AbstractAjaxBehavior::onRequest never called due to redirect url dropping the callback url

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Take a look at
https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/autocomplete-tagit-parent/autocomplete-tagit
This is an integration with TagIt which is an extension of JQuery UI
Autocomplete.

On Mon, Dec 12, 2011 at 1:20 AM, Jeffrey Schwartz
<je...@gmail.com>wrote:

> Summary of problem:  AbstractAjaxBehavior::onRequestMethod not called on
> redirect.
>
> I am using jQuery UI autocomplete. I cannot get it to work with Wicket
> 1.5. The issue appears to be that the original request which includes the
> listener's address is redirected by the server (tried both Glassfish and
> Apache Tomcat) but the redirect url doesn't include the listener's address
> parameter.
>
> I know my jQuery UI is installed and working correctly because I created a
> simple Servlet app and the servlet is receiving the request without
> redirecting and the request includes the request params as well.
>
> Here's the code I am using on the server:
>
>         add(aab2 = new AbstractAjaxBehavior() {
>
>             // handle the ajax request
>             @Override
>             public void onRequest() {
>                 System.out.println("aab2 ajax request received");
>
> //                RequestCycle requestCycle =
> getComponent().getRequestCycle();
> //                Request request = requestCycle.getRequest();
> //                IRequestParameters irp = request.getPostParameters();
> //                StringValue state = irp.getParameterValue("state");
> //                List<String> statesLike =
> MockDb.getStatesLike(state.toString());
> //                requestCycle.scheduleRequestHandlerAfterCurrent(new
> TextRequestHandler("application/json","UTF-8",convertListToJson(statesLike)));
>             }
>         });
>
>         add(myScript = new Label("myScript", "var callbackUrl = '" +
> aab2.getCallbackUrl() + "'"));
>         myScript.setEscapeModelStrings(false);
>
> Here's the client side Javascript code:
>
> $('input.jqueryid_state').autocomplete({source: callbackUrl});
>
> My dev environment is Mac OS X Lion & Netbeans 7.0.1 if that matters. I am
> using Wicket v1.5.1.
>
> When running the code the server log never show the message "aab2 ajax
> request received" and Safari's Web Inspector dev tool reports the
> redirect along with the truncated url and the response to that is that
> Wicket renders the whole page.
>
> Here's what I see in Safari Web Inspector:
>
>
>
>
> As can be seen from the above images the original GET request included the
> call back url but the redirect does not.
>
> Am I doing something wrong and does any one have a suggestion/idea?
>
> Thanks in advance,
> Jeff
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>