You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Marco Gattei <ma...@gmail.com> on 2010/02/16 13:41:11 UTC
ClickClick Jquery Autocomplete
Hi everyone ,
i'm trying to play with Jquery AutoCompleteField from wobnderful clickclick
project ....
What i'm trying to do is submit extra params to the server when requesting
the list for autocomplete field.
(i.e. i choose state first, then autosuggest city that are only in that
state ).
Jquery autocomplete plugin has a nice feature that allow to define extra
params to send with the ajax request for autocomplete.
http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
I tried it, but when i set this particular option, the server method for
getting suggestion list doesn't get invoked !!!!
Removing the option from jquery $('selector').autocomplete( url , options )
gets JQAutoCompleteField to work again.
I tried to sniff HTTP dialog between client and server and i noticed that
where JQuery autocomplete with extraParam options on,
request to the server are made whit type='application/xml' .
When extraParam is off, request type = 'text/plain'.
It seems like when request type of the ajax request is not text/plain, Click
isn't able to invoke the JQAutoCompleteFiled listener.
As someone any idea ?
Is that a Click or a JQuery iussue ?
--
Marco
Re: ClickClick Jquery Autocomplete
Posted by Bob Schellink <sa...@gmail.com>.
On 18/02/2010 05:49 AM, AndreyRybin wrote:
>
> http://jackson.codehaus.org/ looks like #1 java JSON lib.
>
> http://code.google.com/p/google-gson/ looks nice (omg! it's google), but it
> several time slower then jackson
We only need a JSON writer, so I'm thinking along the lines of this:
http://stringtree.svn.sourceforge.net/viewvc/stringtree/trunk/src/main/java/org/stringtree/json/JSONWriter.java?revision=518&view=markup
Haven't tested the class so maybe it won't work for our use case.
kind regards
bob
Re: ClickClick Jquery Autocomplete
Posted by AndreyRybin <ap...@gmail.com>.
http://jackson.codehaus.org/ looks like #1 java JSON lib.
http://code.google.com/p/google-gson/ looks nice (omg! it's google), but it
several time slower then jackson
--
View this message in context: http://n2.nabble.com/ClickClick-Jquery-Autocomplete-tp4580014p4587787.html
Sent from the click-development mailing list archive at Nabble.com.
Re: ClickClick Jquery Autocomplete
Posted by Bob Schellink <sa...@gmail.com>.
On 17/02/2010 09:12 AM, Bob Schellink wrote:
>
> {key: value, key: value {nested-key: nested-value, nested-key:
> nested-value}}
Hrm, that should be:
{key: value, key: {nested-key: nested-value}}
We'll definitely need a Java-JSON API!
Re: ClickClick Jquery Autocomplete
Posted by Bob Schellink <sa...@gmail.com>.
Hi Marco,
If you want commit access to ClickClick let me know. Please note that Click itself might support
Ajax in a future release which will impact ClickClick. For example if we introduce behaviors in
Click, then ClickClick Helper objects would very likely be refactored into these behaviors.
In the changes you made to AutoComplete I'd suggest that "options" should always be rendered. That
way, even if a new version of AutoComplete is released, its new options can easily be used without
having to release a new version of AutoComplete.
Perhaps options should be a map as well? Most JavaScript options are JSON based so perhaps we should
look for a small JSON third-party library, or write one ourselves. For example a Map could be
rendered as:
{key: value, key: value}
and a Map of Maps could become:
{key: value, key: value {nested-key: nested-value, nested-key: nested-value}}
kind regards
bob
On 17/02/2010 03:41 AM, Marco Gattei wrote:
> If anyone is interested code in the attachment
>
> 1) javascript template file,
>
> 2) Helper java class with extended properties for Jquery autocomplete option
>
> 3) demo page
>
> Marco
>
> 2010/2/16, Marco Gattei<ma...@gmail.com>:
>> Fix works like a charm ...
>>
>> Marco
>>
>> 2010/2/16 Bob Schellink<sa...@gmail.com>
>>
>>> Hi Marco,
>>>
>>> I've just checked in a fix for jquery.autocomplete.js to pass the element
>>> ID attribute to the server. Thus the jquery.autocomplete.template.js
>>> doesn't
>>> need to use extraParams anymore.
>>>
>>> Changes can be seen here:
>>>
>>> http://code.google.com/p/clickclick/source/detail?r=511
>>>
>>> Having an API to specify extra params would be good. I don't think it
>>> matters that the JQuery AutoCompleteField is dependent on JQuery. The
>>> extraParams would be dependent on the AutoComplete plugin options anyway.
>>>
>>> kind regards
>>>
>>> bob
>>>
>>>
>>>
>>> On 17/02/2010 12:49 AM, Marco Gattei wrote:
>>>
>>>> Damn ! how could i've been so blind ?
>>>>
>>>> By the way, i'm workin on it ... i think about adding properties in
>>>> JQAutoCompleteHelper some properties
>>>> to mirror Jquery autocomplete options so in java code you can do:
>>>>
>>>> autocompField.getJQueryHelper().addExtraParam( "paramname" ,
>>>> "js_code_to_get_value" );
>>>>
>>>> param would be held internally by the Helper as a map , with ID already
>>>> set .....
>>>>
>>>> I've used this approach to create a JQDialogHelper and worked well for
>>>> me.
>>>>
>>>> Only drawback i can see is that the component gets VERY dependent from
>>>> the libray javascript underneath...
>>>> but after all you are using clickclick-jquery !
>>>>
>>>> By the way, great work bob
>>>>
>>>> Marco
>>>>
>>>>
>>>>
>>>>
>>>> 2010/2/16 Bob Schellink<sa...@gmail.com>>
>>>>
>>>>
>>>> Hi Marco,
>>>>
>>>> AutoCompleteField uses the template jquery.autocomplete.template.js.
>>>> If you look at the template you'll notice that it already uses the
>>>> extraParams property to send the field ID parameter to the server.
>>>> If you specify extraParams it overrides the default value and Click
>>>> cannot figure out which field sent the request.
>>>>
>>>> To fix this we'll need to "append" extraParams instead of replace
>>>> them.
>>>>
>>>> For now you can work around this by specifying your extraParams as
>>>> follows:
>>>>
>>>> setOptions("extraParams: {" + completeField.getId() + ":1,<add
>>>> custom params here>}");
>>>>
>>>> kind regards
>>>>
>>>> bob
>>>>
>>>>
>>>> On 16/02/2010 11:41 PM, Marco Gattei wrote:
>>>>
>>>> Hi everyone ,
>>>>
>>>> i'm trying to play with Jquery AutoCompleteField from wobnderful
>>>> clickclick project ....
>>>> What i'm trying to do is submit extra params to the server when
>>>> requesting the list for autocomplete field.
>>>> (i.e. i choose state first, then autosuggest city that are only
>>>> in that
>>>> state ).
>>>> Jquery autocomplete plugin has a nice feature that allow to
>>>> define extra
>>>> params to send with the ajax request for autocomplete.
>>>>
>>>>
>>>> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>>>>
>>>> I tried it, but when i set this particular option, the server
>>>> method for
>>>> getting suggestion list doesn't get invoked !!!!
>>>> Removing the option from jquery $('selector').autocomplete( url ,
>>>> options ) gets JQAutoCompleteField to work again.
>>>>
>>>> I tried to sniff HTTP dialog between client and server and i
>>>> noticed
>>>> that where JQuery autocomplete with extraParam options on,
>>>> request to the server are made whit type='application/xml' .
>>>> When extraParam is off, request type = 'text/plain'.
>>>> It seems like when request type of the ajax request is not
>>>> text/plain,
>>>> Click isn't able to invoke the JQAutoCompleteFiled listener.
>>>>
>>>> As someone any idea ?
>>>>
>>>> Is that a Click or a JQuery iussue ?
>>>>
>>>> --
>>>> Marco
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Marco
>>>>
>>>
>>>
>>
>>
>> --
>> Marco
>>
>
>
Re: ClickClick Jquery Autocomplete
Posted by Marco Gattei <ma...@gmail.com>.
If anyone is interested code in the attachment
1) javascript template file,
2) Helper java class with extended properties for Jquery autocomplete option
3) demo page
Marco
2010/2/16, Marco Gattei <ma...@gmail.com>:
> Fix works like a charm ...
>
> Marco
>
> 2010/2/16 Bob Schellink <sa...@gmail.com>
>
>> Hi Marco,
>>
>> I've just checked in a fix for jquery.autocomplete.js to pass the element
>> ID attribute to the server. Thus the jquery.autocomplete.template.js
>> doesn't
>> need to use extraParams anymore.
>>
>> Changes can be seen here:
>>
>> http://code.google.com/p/clickclick/source/detail?r=511
>>
>> Having an API to specify extra params would be good. I don't think it
>> matters that the JQuery AutoCompleteField is dependent on JQuery. The
>> extraParams would be dependent on the AutoComplete plugin options anyway.
>>
>> kind regards
>>
>> bob
>>
>>
>>
>> On 17/02/2010 12:49 AM, Marco Gattei wrote:
>>
>>> Damn ! how could i've been so blind ?
>>>
>>> By the way, i'm workin on it ... i think about adding properties in
>>> JQAutoCompleteHelper some properties
>>> to mirror Jquery autocomplete options so in java code you can do:
>>>
>>> autocompField.getJQueryHelper().addExtraParam( "paramname" ,
>>> "js_code_to_get_value" );
>>>
>>> param would be held internally by the Helper as a map , with ID already
>>> set .....
>>>
>>> I've used this approach to create a JQDialogHelper and worked well for
>>> me.
>>>
>>> Only drawback i can see is that the component gets VERY dependent from
>>> the libray javascript underneath...
>>> but after all you are using clickclick-jquery !
>>>
>>> By the way, great work bob
>>>
>>> Marco
>>>
>>>
>>>
>>>
>>> 2010/2/16 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>>>
>>>
>>> Hi Marco,
>>>
>>> AutoCompleteField uses the template jquery.autocomplete.template.js.
>>> If you look at the template you'll notice that it already uses the
>>> extraParams property to send the field ID parameter to the server.
>>> If you specify extraParams it overrides the default value and Click
>>> cannot figure out which field sent the request.
>>>
>>> To fix this we'll need to "append" extraParams instead of replace
>>> them.
>>>
>>> For now you can work around this by specifying your extraParams as
>>> follows:
>>>
>>> setOptions("extraParams: {" + completeField.getId() + ":1, <add
>>> custom params here>}");
>>>
>>> kind regards
>>>
>>> bob
>>>
>>>
>>> On 16/02/2010 11:41 PM, Marco Gattei wrote:
>>>
>>> Hi everyone ,
>>>
>>> i'm trying to play with Jquery AutoCompleteField from wobnderful
>>> clickclick project ....
>>> What i'm trying to do is submit extra params to the server when
>>> requesting the list for autocomplete field.
>>> (i.e. i choose state first, then autosuggest city that are only
>>> in that
>>> state ).
>>> Jquery autocomplete plugin has a nice feature that allow to
>>> define extra
>>> params to send with the ajax request for autocomplete.
>>>
>>>
>>> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>>>
>>> I tried it, but when i set this particular option, the server
>>> method for
>>> getting suggestion list doesn't get invoked !!!!
>>> Removing the option from jquery $('selector').autocomplete( url ,
>>> options ) gets JQAutoCompleteField to work again.
>>>
>>> I tried to sniff HTTP dialog between client and server and i
>>> noticed
>>> that where JQuery autocomplete with extraParam options on,
>>> request to the server are made whit type='application/xml' .
>>> When extraParam is off, request type = 'text/plain'.
>>> It seems like when request type of the ajax request is not
>>> text/plain,
>>> Click isn't able to invoke the JQAutoCompleteFiled listener.
>>>
>>> As someone any idea ?
>>>
>>> Is that a Click or a JQuery iussue ?
>>>
>>> --
>>> Marco
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Marco
>>>
>>
>>
>
>
> --
> Marco
>
--
Marco
Re: ClickClick Jquery Autocomplete
Posted by Marco Gattei <ma...@gmail.com>.
Fix works like a charm ...
Marco
2010/2/16 Bob Schellink <sa...@gmail.com>
> Hi Marco,
>
> I've just checked in a fix for jquery.autocomplete.js to pass the element
> ID attribute to the server. Thus the jquery.autocomplete.template.js doesn't
> need to use extraParams anymore.
>
> Changes can be seen here:
>
> http://code.google.com/p/clickclick/source/detail?r=511
>
> Having an API to specify extra params would be good. I don't think it
> matters that the JQuery AutoCompleteField is dependent on JQuery. The
> extraParams would be dependent on the AutoComplete plugin options anyway.
>
> kind regards
>
> bob
>
>
>
> On 17/02/2010 12:49 AM, Marco Gattei wrote:
>
>> Damn ! how could i've been so blind ?
>>
>> By the way, i'm workin on it ... i think about adding properties in
>> JQAutoCompleteHelper some properties
>> to mirror Jquery autocomplete options so in java code you can do:
>>
>> autocompField.getJQueryHelper().addExtraParam( "paramname" ,
>> "js_code_to_get_value" );
>>
>> param would be held internally by the Helper as a map , with ID already
>> set .....
>>
>> I've used this approach to create a JQDialogHelper and worked well for me.
>>
>> Only drawback i can see is that the component gets VERY dependent from
>> the libray javascript underneath...
>> but after all you are using clickclick-jquery !
>>
>> By the way, great work bob
>>
>> Marco
>>
>>
>>
>>
>> 2010/2/16 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>>
>>
>> Hi Marco,
>>
>> AutoCompleteField uses the template jquery.autocomplete.template.js.
>> If you look at the template you'll notice that it already uses the
>> extraParams property to send the field ID parameter to the server.
>> If you specify extraParams it overrides the default value and Click
>> cannot figure out which field sent the request.
>>
>> To fix this we'll need to "append" extraParams instead of replace them.
>>
>> For now you can work around this by specifying your extraParams as
>> follows:
>>
>> setOptions("extraParams: {" + completeField.getId() + ":1, <add
>> custom params here>}");
>>
>> kind regards
>>
>> bob
>>
>>
>> On 16/02/2010 11:41 PM, Marco Gattei wrote:
>>
>> Hi everyone ,
>>
>> i'm trying to play with Jquery AutoCompleteField from wobnderful
>> clickclick project ....
>> What i'm trying to do is submit extra params to the server when
>> requesting the list for autocomplete field.
>> (i.e. i choose state first, then autosuggest city that are only
>> in that
>> state ).
>> Jquery autocomplete plugin has a nice feature that allow to
>> define extra
>> params to send with the ajax request for autocomplete.
>>
>>
>> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>>
>> I tried it, but when i set this particular option, the server
>> method for
>> getting suggestion list doesn't get invoked !!!!
>> Removing the option from jquery $('selector').autocomplete( url ,
>> options ) gets JQAutoCompleteField to work again.
>>
>> I tried to sniff HTTP dialog between client and server and i
>> noticed
>> that where JQuery autocomplete with extraParam options on,
>> request to the server are made whit type='application/xml' .
>> When extraParam is off, request type = 'text/plain'.
>> It seems like when request type of the ajax request is not
>> text/plain,
>> Click isn't able to invoke the JQAutoCompleteFiled listener.
>>
>> As someone any idea ?
>>
>> Is that a Click or a JQuery iussue ?
>>
>> --
>> Marco
>>
>>
>>
>>
>>
>> --
>> Marco
>>
>
>
--
Marco
Re: ClickClick Jquery Autocomplete
Posted by Bob Schellink <sa...@gmail.com>.
Hi Marco,
I've just checked in a fix for jquery.autocomplete.js to pass the element ID attribute to the
server. Thus the jquery.autocomplete.template.js doesn't need to use extraParams anymore.
Changes can be seen here:
http://code.google.com/p/clickclick/source/detail?r=511
Having an API to specify extra params would be good. I don't think it matters that the JQuery
AutoCompleteField is dependent on JQuery. The extraParams would be dependent on the AutoComplete
plugin options anyway.
kind regards
bob
On 17/02/2010 12:49 AM, Marco Gattei wrote:
> Damn ! how could i've been so blind ?
>
> By the way, i'm workin on it ... i think about adding properties in
> JQAutoCompleteHelper some properties
> to mirror Jquery autocomplete options so in java code you can do:
>
> autocompField.getJQueryHelper().addExtraParam( "paramname" ,
> "js_code_to_get_value" );
>
> param would be held internally by the Helper as a map , with ID already
> set .....
>
> I've used this approach to create a JQDialogHelper and worked well for me.
>
> Only drawback i can see is that the component gets VERY dependent from
> the libray javascript underneath...
> but after all you are using clickclick-jquery !
>
> By the way, great work bob
>
> Marco
>
>
>
>
> 2010/2/16 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>
> Hi Marco,
>
> AutoCompleteField uses the template jquery.autocomplete.template.js.
> If you look at the template you'll notice that it already uses the
> extraParams property to send the field ID parameter to the server.
> If you specify extraParams it overrides the default value and Click
> cannot figure out which field sent the request.
>
> To fix this we'll need to "append" extraParams instead of replace them.
>
> For now you can work around this by specifying your extraParams as
> follows:
>
> setOptions("extraParams: {" + completeField.getId() + ":1, <add
> custom params here>}");
>
> kind regards
>
> bob
>
>
> On 16/02/2010 11:41 PM, Marco Gattei wrote:
>
> Hi everyone ,
>
> i'm trying to play with Jquery AutoCompleteField from wobnderful
> clickclick project ....
> What i'm trying to do is submit extra params to the server when
> requesting the list for autocomplete field.
> (i.e. i choose state first, then autosuggest city that are only
> in that
> state ).
> Jquery autocomplete plugin has a nice feature that allow to
> define extra
> params to send with the ajax request for autocomplete.
>
> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>
> I tried it, but when i set this particular option, the server
> method for
> getting suggestion list doesn't get invoked !!!!
> Removing the option from jquery $('selector').autocomplete( url ,
> options ) gets JQAutoCompleteField to work again.
>
> I tried to sniff HTTP dialog between client and server and i noticed
> that where JQuery autocomplete with extraParam options on,
> request to the server are made whit type='application/xml' .
> When extraParam is off, request type = 'text/plain'.
> It seems like when request type of the ajax request is not
> text/plain,
> Click isn't able to invoke the JQAutoCompleteFiled listener.
>
> As someone any idea ?
>
> Is that a Click or a JQuery iussue ?
>
> --
> Marco
>
>
>
>
>
> --
> Marco
Re: ClickClick Jquery Autocomplete
Posted by Marco Gattei <ma...@gmail.com>.
Damn ! how could i've been so blind ?
By the way, i'm workin on it ... i think about adding properties in
JQAutoCompleteHelper some properties
to mirror Jquery autocomplete options so in java code you can do:
autocompField.getJQueryHelper().addExtraParam( "paramname" ,
"js_code_to_get_value" );
param would be held internally by the Helper as a map , with ID already set
.....
I've used this approach to create a JQDialogHelper and worked well for me.
Only drawback i can see is that the component gets VERY dependent from the
libray javascript underneath...
but after all you are using clickclick-jquery !
By the way, great work bob
Marco
2010/2/16 Bob Schellink <sa...@gmail.com>
> Hi Marco,
>
> AutoCompleteField uses the template jquery.autocomplete.template.js. If you
> look at the template you'll notice that it already uses the extraParams
> property to send the field ID parameter to the server. If you specify
> extraParams it overrides the default value and Click cannot figure out which
> field sent the request.
>
> To fix this we'll need to "append" extraParams instead of replace them.
>
> For now you can work around this by specifying your extraParams as follows:
>
> setOptions("extraParams: {" + completeField.getId() + ":1, <add custom
> params here>}");
>
> kind regards
>
> bob
>
>
> On 16/02/2010 11:41 PM, Marco Gattei wrote:
>
>> Hi everyone ,
>>
>> i'm trying to play with Jquery AutoCompleteField from wobnderful
>> clickclick project ....
>> What i'm trying to do is submit extra params to the server when
>> requesting the list for autocomplete field.
>> (i.e. i choose state first, then autosuggest city that are only in that
>> state ).
>> Jquery autocomplete plugin has a nice feature that allow to define extra
>> params to send with the ajax request for autocomplete.
>>
>> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>>
>> I tried it, but when i set this particular option, the server method for
>> getting suggestion list doesn't get invoked !!!!
>> Removing the option from jquery $('selector').autocomplete( url ,
>> options ) gets JQAutoCompleteField to work again.
>>
>> I tried to sniff HTTP dialog between client and server and i noticed
>> that where JQuery autocomplete with extraParam options on,
>> request to the server are made whit type='application/xml' .
>> When extraParam is off, request type = 'text/plain'.
>> It seems like when request type of the ajax request is not text/plain,
>> Click isn't able to invoke the JQAutoCompleteFiled listener.
>>
>> As someone any idea ?
>>
>> Is that a Click or a JQuery iussue ?
>>
>> --
>> Marco
>>
>
>
--
Marco
Re: ClickClick Jquery Autocomplete
Posted by Bob Schellink <sa...@gmail.com>.
Hi Marco,
AutoCompleteField uses the template jquery.autocomplete.template.js. If you look at the template
you'll notice that it already uses the extraParams property to send the field ID parameter to the
server. If you specify extraParams it overrides the default value and Click cannot figure out which
field sent the request.
To fix this we'll need to "append" extraParams instead of replace them.
For now you can work around this by specifying your extraParams as follows:
setOptions("extraParams: {" + completeField.getId() + ":1, <add custom params here>}");
kind regards
bob
On 16/02/2010 11:41 PM, Marco Gattei wrote:
> Hi everyone ,
>
> i'm trying to play with Jquery AutoCompleteField from wobnderful
> clickclick project ....
> What i'm trying to do is submit extra params to the server when
> requesting the list for autocomplete field.
> (i.e. i choose state first, then autosuggest city that are only in that
> state ).
> Jquery autocomplete plugin has a nice feature that allow to define extra
> params to send with the ajax request for autocomplete.
>
> http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields.
>
> I tried it, but when i set this particular option, the server method for
> getting suggestion list doesn't get invoked !!!!
> Removing the option from jquery $('selector').autocomplete( url ,
> options ) gets JQAutoCompleteField to work again.
>
> I tried to sniff HTTP dialog between client and server and i noticed
> that where JQuery autocomplete with extraParam options on,
> request to the server are made whit type='application/xml' .
> When extraParam is off, request type = 'text/plain'.
> It seems like when request type of the ajax request is not text/plain,
> Click isn't able to invoke the JQAutoCompleteFiled listener.
>
> As someone any idea ?
>
> Is that a Click or a JQuery iussue ?
>
> --
> Marco