Hi, all
I sent an email about how to inject service object to wicket sortable
models, and got some suggestions. then I tried these below:
1.make sure that guice works well with wicket. I can inject service to Pages
by set method with @Inject.
2.I know I can not inject to models, so I add the following jars (salve) to
the classpath:
salve-contract-2.0-SNAPSHOT.jar
salve-depend-2.0-SNAPSHOT.jar
salve-depend-guice-2.0-SNAPSHOT.jar
salve-inst-2.0-SNAPSHOT.jar
3.I use the following code to tell wicket about the guice module
@Override
public void addComponentInstantiationListener() {
addComponentInstantiationListener(new GuiceComponentInjector(this,
new WebsiteModule()));
}
4.I use the folling code to get Guice Injector
Injector injector =
getMetaData(GuiceInjectorHolder.INJECTOR_KEY).getInjector();
(with debug info, I get injector, and I believe it is not null)
5.init Salve with following code:
DependencyLibrary.addLocator(new GuiceBeanLocator(injector));
ok, I use @Dependency instead of @Inject as:
@Dependency private ServiceProvider provider;
but with debug info, provider always be null and I got nullpointException.
Can anybody help me to find what steps I forget?
Thanks!
--
------------------
Enjoy. Thanks!
Haulyn Microproduction
Mobile: +086-15864011231
email: [email protected],
[email protected]
website: http://haulynjason.net
gtalk: [email protected]
yahoo: [email protected]
msn: [email protected]
skype: saharabear
QQ: 378606292
Haulyn Jason