!!!I am so stupid, I didn't check the source of wicket, just image that
InjectorHolder keep it's own context with Guice Injector, but it is not.
just like Guice, I need to inject(this), but the first, I have to get
Injector. I try to use InjectorHolder.getInjector(), but I got null, then I
try to
use 
WebsiteApplication.get().getMetaData(GuiceInjectorHolder.INJECTOR_KEY).getInjector().injectMembers(this);
ok, I got the application, everything works well now!


Thanks everyone, and especially thanks to Igor. I do not need to use salve
now, but I am interesting at salve, if I have time, I will deep in it.

On Wed, Aug 19, 2009 at 10:27 AM, Haulyn R. Jason <[email protected]>wrote:

> I do this, but it looks that just work for spring but not Guice.
>
>
> On Wed, Aug 19, 2009 at 10:24 AM, Igor Vaynberg 
> <[email protected]>wrote:
>
>> it is possible if you can get a hold of a ConfigurableInjector
>> instance which is usually obtained via InjectorHolder.getInjector().
>> once you do you can call injector.inject(this) in the constructor of
>> the class and it will be injected.
>>
>> -igor
>>
>> On Tue, Aug 18, 2009 at 6:35 PM, Haulyn R. Jason<[email protected]>
>> wrote:
>> > Thanks Igor,
>> > If it is possible to inject service to models in wicket,  I will go to
>> salve
>> > mailing list for help. Thank you.
>> >
>> >
>> > On Wed, Aug 19, 2009 at 12:00 AM, Igor Vaynberg <
>> [email protected]>wrote:
>> >
>> >> a) use 1.1 jars - link to their maven repo is on the front page under
>> news
>> >> b) salve is a bytecode instrumentor - that means you have to
>> >> instrument your classes. there are various ways to do it: eclipse/idea
>> >> plugin, maven plugin, jvm agent. how to set all this up is on the
>> >> salve wiki.
>> >> c) salve has its own mailing list - if your questions are salve
>> >> related please use that instead of polluting this list.
>> >>
>> >> -igor
>> >>
>> >> On Tue, Aug 18, 2009 at 8:09 AM, Haulyn R. Jason<[email protected]>
>> >> wrote:
>> >> > 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
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> >
>> > --
>> > ------------------
>> > 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
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> ------------------
> 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
>
>
>


-- 
------------------
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

Reply via email to