Showing posts with label ValidationTabLib. Show all posts
Showing posts with label ValidationTabLib. Show all posts

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