tiistai 6. huhtikuuta 2010

Using session-scoped services in Grails' taglib

Using services with session scope in tag libraries does not work in Grails, as per version 1.2.2. There's a fix promised in 1.3.0, but while waiting for it to be released, here's a simple workaround:

import org.springframework.context.ApplicationContextAware
import org.springframework.context.ApplicationContext

class DefaultTagLib implements ApplicationContextAware {
ApplicationContext applicationContext

def someTag = {attrs, body ->
applicationContext.documentService.doSomething()
}
}

Ei kommentteja:

Lähetä kommentti