Guice + SimpleTagSupport

30 views
Skip to first unread message

Stefan

unread,
Nov 3, 2009, 12:45:22 PM11/3/09
to google-guice
We have quite an extensive tag library which could benefit from proper
dependency injection - is there anyway to get Guice to inject classes
that extend SimpleTagSupport? I'm guessing standard guice-servlet will
not help me here?

Appreciate your help,
Stefan

Brian Pontarelli

unread,
Nov 3, 2009, 1:18:14 PM11/3/09
to google...@googlegroups.com
If your Injector is in a singleton or the ServletContext, just grab it
out and call:

getMemberInjector(this.getClass()).injectMembers(this);

I do this in the constructor or the setPageContext method or any of
the other methods. Also, watch out for tag instance pooling depending
on your use cases.

-bp

Stefan

unread,
Nov 3, 2009, 5:44:12 PM11/3/09
to google-guice
Works like a charm! Thanks Brian for such a quick reply to a newbie
question :)

Best regards,
Stefan
Reply all
Reply to author
Forward
0 new messages