You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dgn <da...@hms.harvard.edu> on 2013/12/13 17:39:47 UTC

Generating email from template outside request/response cycle

Hello-

I'm attempting to use the Wicket 6 email templating mechanism to render an
HTML email from a Panel OUTSIDE the normal request/response cycle -- in a
timer thread. I have already been successful generating email from within a
normal request by following the examples at
http://www.wicket-library.com/wicket-examples/mailtemplate/

The timer thread periodically checks the database for a particular situation
and, if the requirements are met, an email is generated.

I have searched in vain in this forum for a solution. Two main problems I am
running into are:
- Getting the error message "There is no application attached to current
thread"
- Using @SpringBean does not work outside the Wicket context. This is true
even if I start the time thread within Application.init()

I'd prefer to generate the email from a Panel as I already have those in
place but would definitely be willing to do so from a page.

Thanks!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generating-email-from-template-outside-request-response-cycle-tp4663011.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Generating email from template outside request/response cycle

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You can export the Application as thread local manually.
See for example:
https://github.com/apache/wicket/blob/442932d4e4c5cc27940bc2ef956cb24c1ba54df0/wicket-experimental/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L200
Make sure you reset it to null at the end.

Martin Grigorov
Wicket Training & Consulting


On Fri, Dec 13, 2013 at 6:39 PM, dgn <da...@hms.harvard.edu> wrote:

> Hello-
>
> I'm attempting to use the Wicket 6 email templating mechanism to render an
> HTML email from a Panel OUTSIDE the normal request/response cycle -- in a
> timer thread. I have already been successful generating email from within a
> normal request by following the examples at
> http://www.wicket-library.com/wicket-examples/mailtemplate/
>
> The timer thread periodically checks the database for a particular
> situation
> and, if the requirements are met, an email is generated.
>
> I have searched in vain in this forum for a solution. Two main problems I
> am
> running into are:
> - Getting the error message "There is no application attached to current
> thread"
> - Using @SpringBean does not work outside the Wicket context. This is true
> even if I start the time thread within Application.init()
>
> I'd prefer to generate the email from a Panel as I already have those in
> place but would definitely be willing to do so from a page.
>
> Thanks!
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Generating-email-from-template-outside-request-response-cycle-tp4663011.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Generating email from template outside request/response cycle

Posted by Steve <sh...@gmail.com>.
Derived from Wicket's ComponentRender class:

https://bitbucket.org/shadders/wicket-el/src/a41127f0771a4b792255cfc0c2ec47c500db1b1b/src/main/java/com/shadworld/wicket/render/Renderer.java?at=default

Not sure if it will solve the SpringBean problem but it it will work
outside a wicket application.

Renderer.init();
CharSequence html = Renderer.renderComponent(myPanel);

On 14/12/13 02:39, dgn wrote:
> Hello-
>
> I'm attempting to use the Wicket 6 email templating mechanism to render an
> HTML email from a Panel OUTSIDE the normal request/response cycle -- in a
> timer thread. I have already been successful generating email from within a
> normal request by following the examples at
> http://www.wicket-library.com/wicket-examples/mailtemplate/
>
> The timer thread periodically checks the database for a particular situation
> and, if the requirements are met, an email is generated.
>
> I have searched in vain in this forum for a solution. Two main problems I am
> running into are:
> - Getting the error message "There is no application attached to current
> thread"
> - Using @SpringBean does not work outside the Wicket context. This is true
> even if I start the time thread within Application.init()
>
> I'd prefer to generate the email from a Panel as I already have those in
> place but would definitely be willing to do so from a page.
>
> Thanks!
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generating-email-from-template-outside-request-response-cycle-tp4663011.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org