By default, grails just gives users a multi-select box when dealing with to-Many relationships in views. It’s damn ugly and incredibly ineffective if an end user is dealing with tons of things to select from. After tolerating it for a while I completely gave up and decided to write my own replacement for it using autocomplete from the richui plugin and prototype which is included with grails.
So, the first thing you’re going to want to do is install the richui plugin, you can do this by running:
grails install-plugin richui
In the directory of your project.
Now, for the example that I’m going to use, there are two classes, Author and Book, an author hasMany Books. So that’s what we’re going to work with. I wrote a little TagLib that you can use, so I’m not going to explain that code, but I’ll show it to you below.
So basically, you need to write a controller for the autoComplete which you can find here, and you use my tag lib, below: Continue reading