Rendering templates in services

If you want to render gsp template on level of service (or in any other bean), just get org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib bean from spring context, and call method render on it:

  1.  
  2. class FooService {
  3.  
  4. boolean transactional = false
  5.  
  6. def grailsApplication
  7.  
  8. def bar(view, model) {
  9. render(template:"/templates/emails/${view}", model:model)
  10. }
  11.  
  12. private def render(args){
  13. grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib').render(args)
  14. }
  15. }
  16.  

Grails 1.1.2 released

Today was released Grails 1.1.2 . There are some bug fixes and new functionalities (changelog). Rely on Robert Fletcher, version 1.2 will not appear, until Spring 3.0 goes final.

@Validateable – thank you ….

Today I learn about cool feature of Grails, that I missed or maybe it appear recently in documentation. As you probably know, I am talking about @Validateable annotation. Just mark your class with @Validateable and all it instances will provide validation mechanisms, like domain classes and command objects.

Where it can be use? Good example is service level, where the only object that provide such functionality is domain class and initialized command object will be simple POGO, without validation functionality.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.