I love how easy it is to create a link in Grails but often I want to use this same mechanism to create a link in a Service. For example, I have a service that sends out a News Report to a list of subscribers. There a links in the generated email back to the website.
Creating a link in a service turns out to be quite simple. I found this work around at http://jira.codehaus.org/browse/GRAILS-2605.
def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() def visitUs = g.createLink(controller: 'site', action: 'index', absolute: 'true') def manageSubscriptions = g.createLink(controller: 'comm', action: 'index', absolute: 'true')
The absolute: ‘true’ is really important as I am embedded these links in an email.