2

Is there a way of integrating apache click web framework with Google Guice such that I can use @Inject to inject Guice services into page/panel classes ?

Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
joshua
  • 4,118
  • 3
  • 40
  • 53

1 Answers1

2

I used the guice filter on web.xml and added the ClickServlet in guice servlet module. I then did an override on the newPageInstance() method on click servlet and called injector.injectMembers(page) to inject all the dependencies on the newly created page.

Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
joshua
  • 4,118
  • 3
  • 40
  • 53
  • I've recently performed the same kind of stuff with Guice 3.0 but was extremely disappointed with guice-servlet (has lots of problems with forwards and URL containing jsessionid). Finally I have completely abandone guice-servlet to use only web.xml. – jfpoilpret Jun 06 '12 at 20:22
  • 1
    For your ClickServlet subclass, why don't you do `injector.getInstance(pageClass)` instead? This allows for constructor injection in your click pages. – jfpoilpret Jun 06 '12 at 20:26