Another Method for Admin screens with Grails

I came from a background of making sites with Django and after I starting going head-first into Grails, one of the things I missed was a really good and easy to make an admin section. You know — something that “just works” to do some basic CRUD. I know that there is the scaffolding plugin but the problem with that is that it’s not always robust and it’s not easily configurable. I want my admin pages to be look nice as well as being robust.

A little while ago I bumped into the admin-interface plugin, which pretty much does everything that I had hoped for. There is a bit of configuration but it’s not much more than what you had to do in Django. I have a very simple github project for you to play with.

If you look at the bottom of the Config.groovy you will see some simple configurations:

The AuthorAdmin and BookAdmin are little descriptor files that say what fields should appear to be and what order. I found that admin-interface really isn’t that smart — that the fields aren’t listed in any sensible order so I think that file is quite necessary. It’s not even smart enough to remove dateCreated and lastUpdate which Scaffolding does just fine! My sample Author file looked like this:

Admin page with random order

You just have to add the field to the list. This isn’t quite the magic I was hoping for, but it’s only small change, as oppose to generating GSPs or editing them to put in a field.

It’s not like these files are complicated. See below for the Author’s admin file:

And then admin page looks immediately better:

Much better!

I didn’t do it in my example but it can use Spring Security to define what role has access to the Admin section. You can also define the URL and put different domains in logical groups. These are things that this plugin does better than Scaffolding.

I think the admin-interface plugin can easily replace the scaffolding plugin and have happier users too.

About the Author

Mike Hostetler profile.

Mike Hostetler

Principal Technologist

Mike has almost 20 years of experience in technology. He started in networking and Unix administration, and grew into technical support and QA testing. But he has always done some development on the side and decided a few years ago to pursue it full-time. His history of working with users gives Mike a unique perspective on writing software.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Google Professional Machine Learning Engineer Exam 2021
Exam Description A Professional Machine Learning Engineer designs, builds, and productionizes ML models to solve business challenges using Google Cloud technologies and knowledge of proven ML models and techniques. The ML Engineer is proficient in all aspects […]
Designing Kubernetes Controllers
There has been some excellent online discussion lately around Kubernetes controllers, highlighted by an excellent Speakerdeck presentation assembled by Tim Hockin. What I’d like to do in this post is explore some of the implications […]
React Server Components
The React Team recently announced new work they are doing on React Server Components, a new way of rendering React components. The goal is to create smaller bundle sizes, speed up render time, and prevent […]
Jolt custom java transform
Jolt is a JSON to JSON transformation library where the transform is defined in JSON. It’s really good at reorganizing the json data and massaging it into the output JSON you need. Sometimes, you just […]