Hi jan,

On Oct 8, 2009, at 6:47 AM, Jan Kriesten wrote:


Hi Haim,

Yes, I remember seeing that. How would you add it to wicket? by adding ServiceInjector trait to the Application class or using the wicket- guice way (addComponentInstantiationListener(new GuiceComponentInjector(this));)?

the Injector is just a trait, so anywhere it's needed, I just add it to the corresponding class - whether it's a Wicket component or not doesn't matter. So
you have

class MyWebPage extends WebPage with Injector {
 @Inject val domainRepo: DomainRepo = domainRepo
}

class DomainRepo extends Repo with Injector {
 @Inject val customerRepo: CustomerRep = customerRepo
}

This is a general approach, so no need to add a intantiation listener.
This is an interesting approach. From what I remember from guice, you can use it to overcome the problem of having to start all your object by injection (classes that initiated by "new" can not use the injector anymore). But does it preserve the ability to know at startup if all your injections are resolved?

BTW, to test it I need to supply a custom Module since I can not invoke the class without injection. am I right?


One more question though, In the example you're only using constructor
injection. Any reason not to use field injection?

Actually, I use field injection most of the time, see above.

Best regards, --- Jan.

One more question about injections in wicket. How can I handle the session object. Do I have to use the getSession method, or can I inject the session object as well?

Thanks for your help
--
Haim

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to