Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use external data source in jQuery UI

 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am try to use Autocomplete using jQuery UI.

Here is working code for hard code value but I need to use external data (Database) ?

Thanks
AR
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the callback option for the data source. The callback can use Ajax to fetch data from the server.

This is covered in detail in my jQuery in Action, 2nd ed book (section 11.4 to be exact).

Or you can read through the online documentation for autocompleters.
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are examples in the book only for hard coded Array values.
I have StateDao class which have method getStateList() which provides List<String>.
How can I use data from database ?
Thanks
AR
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book describes how to do it.

But essentially your callback will use Ajax to make a request back to the server. The response should contain the data in any of the JSON formats described in the documentation.

Once the request is on the server, the autocompleter could care less what the server-side code does, so your java code can call your DAO in any manner that you see fit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic