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.  

No Comments yet

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

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