I just came across this problem using the datePicker tag in a gsp – it appeared that there was no way to stop the tag showing today’s date when no value was set on the bean. Continue reading
Author Archives: Dave
Sending Asynchronous HTML Email in Grails with ActiveMQ, JMS and Gmail
Sending email asynchronously is an essential part of most Web applications and there are many ways in which to implement it. In this post I’ve chosen to demonstrate how to set up JMS, ActiveMQ and Gmail with the Grails Mail plugin to provide asynchronous email capabilities while only having to write a few lines of code, all thanks to some great plugins. I’ll also show the fantastic Grails Mail templating feature which uses GSP views to generate HTML emails along with a solution for one of the big bugs with it too!
Simple Aspects using Annotations in Grails
Aspect Oriented Programming is a concept which will be familiar to users of the Spring Framework as one of its core features. However, the details of how to get AOP working in Grails appear thin on the ground, so in this post I will show how to set up a simple aspect then configure and apply it using attributes. I will assume some familiarity with Spring AOP so I won’t explain the terminology or general concepts since they are exactly the sameĀ in Java as they are in Grails. Continue reading
Updating the Logged in User with Acegi/Spring Security in Grails
Following on from my post on how to log in a user using the Grails Acegi/Spring Security plugin I stumbled into a new use for the same code when I tried to update a user’s own details while logged in. The security plugin caches the user’s domain object so any changes are not seen until the next login (wholly unhelpful when you’re trying to implement account management on a Website!).
When My Grails App Got Stuck in a Recompilation Loop
The first sign something was wrong was the JVM bombing out with a “java.lang.OutOfMemoryError: PermGen space” error. All I’d done was change a gsp, so I restarted and after a long wait the same thing happened and it was then I noticed that the compiler just kept recompiling 4 classes in a loop until the JVM bombed.
This had happened to me once before when I’d managed to set the time incorrectly on my PC so some of my files appeared to be modified in the future. However this time I’d not done anything of the sort.
How To Locate an Open File in the Project View in Intellij Idea
I’ve been lookin for this keyboard shortcut for ages; in Visual Studio it’s “Show in Solution Explorer” – Ctrl+Alt+L, in Eclipse it’s “Show In” – Alt+Shift+w (Alt+W) but I couldn’t work out what it was in Intellij Idea.
It should allow you to find the file you’re currently editing in the project view and as soon as a project gets at all big it’s essential.
Turns out it’s a terminology thing – it’s called “Select current file or symbol in any view” and the shortcut is:
How To Get the Action and Controller Names in a GSPs
It’s 2am, but I’m on a roll (though my typing is suffering somewhat and focussing has started to become an effort) and I’ve just discovered how to get the action and controller names in a Grails GSP. Continue reading
How to Login a User with the Grails Acegi/Spring Security Plugin
The Grails Spring Security plugin is a wonderful thing and certainly worthy of more time spent on it than in this quick post. It saves days, if not weeks of work, plumbing in the standard security model of most websites. Notwithstanding its obvious benefits, I have noticed that many people struggle with some features of it, especially when retro-fitting it to an existing database schema and I can only assume it’s because the best examples of performing common tasks are only seen when generating the classes from scratch, using the generate-registration and generate-manager scripts.
Grails Filter Fail (Update)
[sigh] Some days just seem to be wasted trying to work out why some apparently simple task cannot be accomplished. The frequency of such days has increased somewhat since I started using Grails – while I am a fan of the framework it is still occasionally buggy and badly documented and I seem to stumble into issues every week.
How to Test if a Function Exists in Javascript
I’m no Javascript expert and I couldn’t work out why it seemed to be so difficult to test to see if a function existed before I called it. In the end Google provided a better way though it wasn’t the most popular suggestion out there, to me it seems the most sensible way:
if (window.myFunctionName) { myFunctionName(); }
Where myFunctionName is the function you’re testing for, of course.