it depends on how you initialize guice. if you are using a servlet
context listener then that creates the injector and sticks it into
servlet context where you can get it.

if you are creating the injector yourself then you have a reference to it.

-igor

On Tue, Aug 18, 2009 at 7:12 AM, Haulyn R. Jason<[email protected]> wrote:
> Hi, all:
> I try to use
>        Injector injector =
> getMetaData(GuiceInjectorHolder.INJECTOR_KEY).getInjector();
>        DependencyLibrary.addLocator(new GuiceBeanLocator(injector));
> in the init() of Application, and use @Dependence instead of @Inject, but I
> got NullPointException.
>
>
>
>
> On Tue, Aug 18, 2009 at 9:30 PM, Haulyn R. Jason <[email protected]>wrote:
>
>> Hi, all:
>> The process of compiling salve is passed, and I tried to setup it and
>> testing. But, how can I get guice injector from wicket?
>> I use the code below in my wicket Application's init function,
>>
>> DependencyLibrary.addLocator(new GuiceBeanLocator(injector));
>>
>> but how can I get the guice injector?
>>
>> thanks!
>>
>>
>>
>> On Tue, Aug 18, 2009 at 5:31 PM, Haulyn R. Jason <[email protected]>wrote:
>>
>>> Hi, Igor, Thanks for your reply, I tried salve but when I compile it,
>>> there are some testing failures. Can you help me to find a binary download
>>> link? Or any other solutions are also great! I need to make salve run with
>>> wicket and guice.
>>> Thanks.
>>>
>>>
>>> On Tue, Aug 18, 2009 at 1:34 AM, Igor Vaynberg 
>>> <[email protected]>wrote:
>>>
>>>> the easiest thing is to inject your component and pass the reference
>>>> into your model.
>>>>
>>>> outside that there is salve.googlecode.com that lets you inject any
>>>> object.
>>>>
>>>> InjectorHolder.getInjector() doesnt work with guice because it is
>>>> possible to have more then one injector - one per module.
>>>>
>>>> -igor
>>>>
>>>> On Mon, Aug 17, 2009 at 8:26 AM, Haulyn R. Jason<[email protected]>
>>>> wrote:
>>>> > Hi, all:
>>>> > I have a class which is likes below:
>>>> >
>>>> >
>>>> > public class DetachableMemberModel extends
>>>> LoadableDetachableModel<Member> {
>>>> >
>>>> >    private final long id;
>>>> >
>>>> >    public DetachableMemberModel(Member m) {
>>>> >        this(m.getId());
>>>> >    }
>>>> >
>>>> >    public DetachableMemberModel(long id) {
>>>> >        if (id == 0) {
>>>> >            throw new IllegalArgumentException();
>>>> >        }
>>>> >        this.id = id;
>>>> >    }
>>>> >
>>>> >   �...@override
>>>> >    public int hashCode() {
>>>> >        return Long.valueOf(id).hashCode();
>>>> >    }
>>>> >
>>>> >   �...@override
>>>> >    public boolean equals(final Object obj) {
>>>> >        if (obj == this) {
>>>> >            return true;
>>>> >        } else if (obj == null) {
>>>> >            return false;
>>>> >        } else if (obj instanceof DetachableMemberModel) {
>>>> >            DetachableMemberModel other = (DetachableMemberModel) obj;
>>>> >            return other.id == id;
>>>> >        }
>>>> >        return false;
>>>> >    }
>>>> >
>>>> >   �...@override
>>>> >    protected Member load() {
>>>> >        // I do not know how to inject this service to
>>>> > Object DetachableMemberModel
>>>> >        return memberService.query(id);
>>>> >    }
>>>> > }
>>>> >
>>>> > please see the last method of this class, I do not know how to inject
>>>> > memberService to this class.
>>>> > If I use @Inject private MemberService memberService, I have to inject
>>>> this
>>>> > class to the WebPage, but I can not bind DetachableMemberModel to any
>>>> > interface.
>>>> >
>>>> > So, I do not know to to implement this, can anybody help me? Thanks
>>>> very
>>>> > much.
>>>> >
>>>> > --
>>>> > ------------------
>>>> > 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
>>
>>
>>
>
>
> --
> ------------------
> 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]

Reply via email to