You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Moxter <ja...@innobix.com> on 2014/03/20 14:27:02 UTC

Additional Parameter fro AutoComplete

Hello Wicket, 


is there a way to send additional parameters from the UserInterface for the ajax call on an AutoComplete. 


The reason for it is that in an form the User can use parameters as a filter for the AutoComplete and i do not want to make so much Ajax Calls just to now what the User has selected. The filters do not import for the model add all, just serve for usability. 


Up to now the only way i found to do this is alter the javascript. for Autocomplete and replace it with a different one. 


Thanks 


Jan 




Re: Additional Parameter fro AutoComplete

Posted by Jan Moxter <ja...@innobix.com>.
Hallo Martin, 

the tickets I found do not include the thins I would need. 

Just to get your opinion on the way i am planning to do this. 

I want to add a a String to AutoCompleteSettings that allows to have a js -function called. That would allow me to alter the Attributes used for the Ajax Call. e.g. add additional parameters from the form 

A code snipplet to try to explain the idea. 

function actualUpdateChoices () { 
showIndicator (); 

var paramName = cfg . parameterName ; 
var attrs = { 
u : callbackUrl , 
pre : [ function ( attributes ) { 
var activeIsInitial = ( document . activeElement === initialElement ); 
var elementVal = Wicket . $ ( elementId ). value ; 
var hasMinimumLength = elementVal . length >= minInputLength ; 
var result = hasMinimumLength && activeIsInitial ; 
if ( ! result ) { 
hideAutoComplete (); 
} 
return result ; 
}], 
ep : {}, 
wr : false , 
dt : 'html' , 
sh : [ doUpdateChoices ] 
}; 
attrs . ep [ paramName ] = Wicket . $ ( elementId ). value ; 

call js function as defined by the Autocomplete Settings that uses the attrs variable as a parameter 

Wicket . Ajax . ajax ( attrs ); 
} 
If i get it to work I would provide a patch 

Thanks 

Jan 
----- Original Message -----

> From: "Martin Grigorov" <mg...@apache.org>
> To: users@wicket.apache.org, "Jan Moxter" <ja...@innobix.com>
> Sent: Thursday, March 20, 2014 9:24:50 AM
> Subject: Re: Additional Parameter fro AutoComplete

> Hi,

> This is not possible at the moment.
> You should either use a copy of wicket-autocomplete.js or
> monkey-patch it to override the methods that deal with the Ajax
> requests.
> There was a ticket with a patch about making this more friendly in
> Wicket 7.x but I cannot find it right now.

> Martin Grigorov
> Wicket Training and Consulting

> On Thu, Mar 20, 2014 at 3:27 PM, Jan Moxter < jan.moxter@innobix.com
> > wrote:

> > Hello Wicket,
> 

> > is there a way to send additional parameters from the UserInterface
> > for the ajax call on an AutoComplete.
> 

> > The reason for it is that in an form the User can use parameters as
> > a
> > filter for the AutoComplete and i do not want to make so much Ajax
> > Calls just to now what the User has selected. The filters do not
> > import for the model add all, just serve for usability.
> 

> > Up to now the only way i found to do this is alter the javascript.
> > for Autocomplete and replace it with a different one.
> 

> > Thanks
> 

> > Jan
> 

Re: Additional Parameter fro AutoComplete

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

This is not possible at the moment.
You should either use a copy of wicket-autocomplete.js or monkey-patch it
to override the methods that deal with the Ajax requests.
There was a ticket with a patch about making this more friendly in Wicket
7.x but I cannot find it right now.

Martin Grigorov
Wicket Training and Consulting


On Thu, Mar 20, 2014 at 3:27 PM, Jan Moxter <ja...@innobix.com> wrote:

> Hello Wicket,
>
>
> is there a way to send additional parameters from the UserInterface for
> the ajax call on an AutoComplete.
>
>
> The reason for it is that in an form the User can use parameters as a
> filter for the AutoComplete and i do not want to make so much Ajax Calls
> just to now what the User has selected. The filters do not import for the
> model add all, just serve for usability.
>
>
> Up to now the only way i found to do this is alter the javascript. for
> Autocomplete and replace it with a different one.
>
>
> Thanks
>
>
> Jan
>
>
>
>