GeeCON Prague 2014*
The moose likes JSF and the fly likes Autocomplete with jquery. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Autocomplete with jquery." Watch "Autocomplete with jquery." New topic
Author

Autocomplete with jquery.

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 190
Hi,

I am using jquery for autocomplete.



Instead of the array I want to use a List from a bean something like this:


What is the syntax ?

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

Try something more like this:


The "$" character has a specific meaning to the EL processor and your use of it in jQuery causes the EL processor to do unexpected things. So I replaced the first "$" with its jQuery long-form equivalent, doubled the second "$" to escape it and converted ${bean.List} to #{bean.List}, although that one probably wasn't necessary.

On the bean list property, please note that this value is static, initialized when the page is first loaded and never changing. Also "List" is not a proper JavaBean property name, since it starts with an upper-case letter.

I don't know enough about using jQuery the way you are doing it to actually give a workable example - these are just general suggestions. I find it easier to use a JSF extension tagset such as RichFaces, which has an autosuggest feature built into it and is much simpler to code and use. Although, ironically, RichFaces handles the AJAX aspects of autocomplete using an internal copy of jQuery.


Customer surveys are for companies who didn't pay proper attention to begin with.
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 190
Hi,

Thanks for your answer
I know about the autocomplete via RichFaces but since I already using tomahawk + Trinidad I am not sure about the impact meaning if those 3 implementation can work together.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

Tomahawk would not be a problem, but Trinidad has a history of conflicts. Look at Tobago. It has an auto-suggest input control, and since it's also part of the MyFaces suite, it should play nice with Trinidad. After all, in the real world, Trinidad and Tobago are one country!
 
 
subject: Autocomplete with jquery.