Sunday, August 30, 2015

Grails Get/Use Http Session In Service Or Util Class

import org.codehaus.groovy.grails.web.util.WebUtils
import javax.servlet.http.HttpSession

HttpSession httpSession = WebUtils.retrieveGrailsWebRequest().request.session

Sunday, August 2, 2015

Grails :: How To Override g Message Tag

1. Create a tab lib (grails-app/taglib)

2. Extend with ValidationTagLib

3. Example

package com.test.taglib

import org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib

class MyCustomTagLib extends ValidationTagLib {
 static validationTagLibStatic = null

    static namespace = "g"

    Closure message = { attrs ->
        ValidationTagLib validationTagLib = validationTagLibStatic ?: (validationTagLibStatic = grailsAttributes.applicationContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib'))
        validationTagLib.message.call(attrs)
    }
}