Quantcast

Problem to send a email into service

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Problem to send a email into service

Max-2
hi everyone, i'm having a problem to send a email into a service using the taglib g.render
let's go, i created a quartz job, that call's a specific service
this service execute an logic and send a email using this plugin grails.org/plugin/mail


so.. i wanna render a template called reminder
to render this template i tried to use in html the g.render
and everytime that, the job is executed
i get this exception
No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.


so, what can i do to render the template into this serivce??

[]s

Lok
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problem to send a email into service

Lok
This post has NOT been accepted by the mailing list yet.
Here is the sample code where you can render your template in email body
mailService.sendMail{
            to "${user.profile.email}"
            subject message(code:"sendConfirmation.subject")
            from "${from_mail}"
            html g.render(template:"sendConfirmationMail", model:[.............])
        }
and you should make sure that you have given right template path.
In the above example, _sendConfirmationMail.gsp is placed in the controller where I'm using it. if you are calling the template form different controller you should give relative path of that template( ex :"/<controllerName>/sendConfirmationMail")

thanks
Lok
Cheers, Lok
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problem to send a email into service

Ian Roberts
In reply to this post by Max-2
On 13/06/2012 05:09, Max wrote:
> so.. i wanna render a template called reminder
> to render this template i tried to use in html the g.render

Instead of

html g.render(template:'/foo/bar', model:model)

use

body(template:'/foo/_bar', model:model)

(note that the template parameter to body includes the leading
underscore in the template name, whereas the template parameter to
g.render doesn't - this caught me out the first few times).

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problem to send a email into service

Max-2
tks Ian, in fact, in body's tag, i used the view:'/foo/_bar'
when i tried to use template, it complained about don't have a specified view


[]s

2012/6/13 Ian Roberts <[hidden email]>
On 13/06/2012 05:09, Max wrote:
> so.. i wanna render a template called reminder
> to render this template i tried to use in html the g.render

Instead of

html g.render(template:'/foo/bar', model:model)

use

body(template:'/foo/_bar', model:model)

(note that the template parameter to body includes the leading
underscore in the template name, whereas the template parameter to
g.render doesn't - this caught me out the first few times).

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...