The coolest things I’ve done so far in Grails
Yesterday was a very productive day for me in my Grails app that I’m working on. From custom tags to spring usage, it was a good day indeed. One of the first things I had to do was implement a simple login, and the first item on the tutorials page was exactly that. Besides the login stuff, it also showed me about the interceptors, which is a pretty cool feature.
GSP Custom Tag
I figured out, well almost, the GSP custom tags. I was looking for a date format (not the date picker) tag and found the code via a lengthy search that turned it up on the Japanese version of the Grails Wiki. So took this code snippet and must have placed it in 4 or 5 different locations without any success in it being found. Finally I gave up and put it in the existing FormatTagLib file. What was really odd though was I kept getting null pointers for the ‘out’ variable. This really baffled me for a good half hour, since all the other methods in that taglib worked just fine. Finally I bounced the server and presto it worked. Odd, but ok.
Spring Mailer
One of the features that I wanted to incorporate was email functionality. I’ve used Spring’s mailer beans before and after a quick look at the wiki on the subject it was a bit confusing. It seems there is discussion on how this should really be done within Grails. Should the email be treated as a view ala MVC or a service, etc. I didn’t care, I just wanted to get it done. I found out that spring beans can/will be injected into corresponding controller properties automatically. Now that I like and just might be one of my favorite features of Grails (to date anyway). No other configuration needed. I had gotten used to how Stripes does this with annotations and rather liked that approach, but this is even nicer. The only drawback I see is lack of readability. i.e. If you didn’t know that was happening you surely couldn’t tell from just reading the code, but good JavaDocs can take care of that. Oh, and the off chance that you happen to name a variable the same as a spring bean id and get some really weird behavior!
So I plugged in the mailer bean and fired off an email right in the controller. I like it.
Job Schedules
The built in integration with Quartz was a nice plus and with a couple lines of code I had nice simple job running. I’ll later expand this to do something truly useful, like email reminders, but I like the no configuration aspect of it.
So far things are going pretty good and I’m focusing more on the user interface side of it and will plug it into a persistent database as well. If all goes well I should have it in production before too long.
Don’t miss anything, subscribe!
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.


Comments
No comments yet.
Leave a comment