Friday, December 16, 2011

Enabling jQuery autocomplete in Grails using Tag and Service

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.

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:




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:

On the GSP page insert the following code

Create a tag and insert the following code