Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Autocomplete with jquery.

 
chen young
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
chen young
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic