Problems with AbstractAutoCompleteBehavior on BookmarkablePages
---------------------------------------------------------------

                 Key: WICKET-4305
                 URL: https://issues.apache.org/jira/browse/WICKET-4305
             Project: Wicket
          Issue Type: Bug
          Components: wicket-extensions
    Affects Versions: 1.5.3
            Reporter: Daniel Peters


AbstractAutoCompleteBehavior internally uses the GET parameter "q".
If you are on a bookmarkable page that also uses the parameter q (very common 
for searches), AutoCompleteTextFields wont work anymore. They will only see the 
original q parameter that has been used to call the page.
The autocomplete appends the q= param to the URL and read it with 
getParameter("q"). Since there are 2 params with the same name now, it will 
always get the first.

My first fix was to rename the autocomplete parameter to something like 
"wicketac:q", but this breaks WicketStuff-objectautocomplete which uses the 
same JS, so this is probably not a good idea.

Another idea was to get the _last_ q-parameter of the URL in 
AbstractAutoCompleteBehavior.
This works quite well...

Code:
protected void respond(final AjaxRequestTarget target)
{
        final RequestCycle requestCycle = RequestCycle.get();
        final List<StringValue> values = 
requestCycle.getRequest().getRequestParameters()
                        .getParameterValues("q");
        final String val = (values != null && values.size() > 0) ? 
values.get(values.size() - 1)
                        .toOptionalString() : null;
        onRequest(val, requestCycle);
}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to