I often use autocomplete for multiple fields on my views. These fields might be from one domain or different domains. Instead of creating multiple actions to handle each request, I created a Tag and a Service to make things easier.
The idea is the jQuery will handle the front end by sending the request to controller and displaying the returned json results in a list. So what I just needed to do was to route that request to a service to get the json result and sent it back to the view. The autoComplete tag make it reusable and the service take care of the rest. This way I will just need to set the domains and property in the gsp. The rest will be handled consistently.
Example:
I want to add autocomplate to my author and isbn field on my view. Each coming from different domain. I just need to set my tags parameters and send it to autoComplete action in one controller.
Add the following tag in your gsp with the information about the domain and field:
Done!
Tag:
Service:
Alidad's Groovy and Grails Adventures
Code Dump
Friday, December 16, 2011
Tuesday, July 19, 2011
Grails remote pagination tag using fancy jQuery pagination plugin
This is a grails tag for remote pagination using jQuery, I just made a tag on top of fancy jquery pagination plugin by Cody for Grails. I used this code for a small program, its far from being a mature code so if you want to use it, use it at your own risk but I hope it can be helpful.
Download the a-fancy-jquery-pagination-plugin from the following url:
http://tympanus.net/codrops/2009/11/17/jpaginate-a-fancy-jquery-pagination-plugin/
On the GSP page insert the following code
Create a tag and insert the following code
Download the a-fancy-jquery-pagination-plugin from the following url:
http://tympanus.net/codrops/2009/11/17/jpaginate-a-fancy-jquery-pagination-plugin/
On the GSP page insert the following code
Create a tag and insert the following code
Subscribe to:
Posts (Atom)