Redirecting to .com (without confusing CloudFoundry…)

It’s a two-for-one today – a “gotcha” and a “how to” all rolled into one, this time about redirecting in a Grails filter.

Much like my favicon woes my initial attempt to redirect to a primary domain (a .com without the “www” prefix) had some unexpected consequences when deployed to a live server on CloudFoundry – I started getting warnings that my site had gone down!

In this post I’ll hopefully save you the panic of CloudFoundry telling you that your site’s not responding when you try to rationalise your domain names!

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!).

Continue reading

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:

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.

Continue reading

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) {

Where myFunctionName is the function you’re testing for, of course.