What is an explicit redirect in Grails?

April 8, 2014 at 8:46 pm  •  Posted in Grails by  •  0 Comments

Why am I writing about an Explicit Redirect?

While working with composite and assigned keys in Grails, I kept running into the following error:

“Cannot redirect for object [OcTesting.OcPreferences : (unsaved)] it is not a domain or has no identifier. Use an explicit redirect instead “

Notice the part about the explicit redirect? The default update, delete, and new each have a line similar to the following:

 What is an Explicit redirect?

Instead of redirecting via an object tied to your domain, you have to manually specify the action to redirect by replacing the original redirect with the following:

The redirect can use any of the typical redirect parameters.

What Causes this error?

Take a look at the source, you will see that if redirect determines that the object passed is null, the exception is thrown.


I hope this helps anyone who comes across this same issue. While it worked for me and my specific project, you may have to do some more work.


Leave a Reply