<g:createlink absolute="true"/>
will *always* render a link that is HTTP and on the unsecured port (80 or 8080), even if the request was of the rendering page was HTTPS. It seems like there should be a property to have it honor the protocol & port of the request.
Actually, looks like this is a known bug: http://jira.codehaus.org/browse/GRAILS-3625
The workaround I used was to create a custom tag that would output the base for an absolute URL:
def baseUrl = {
out << "${request.scheme}://${request.serverName}:${request.serverPort}${request.contextPath}/"
}
I could then chain the tags together to create links I wanted:
${baseUrl()createLink(controller: 'foo', action: 'bar')}
This worked fine enough in my case, the fix was simple, but figuring out there was an actual bug in the framework that required a workaround on my part took some time.
No comments:
Post a Comment