Hello friend,

Do you have access to your injector where you "new" your instance?
I am not sure, but could you try to "new" the instance and then use
your injector like injector.injectMembers(instance). You would need to
put the @Inject above the Dispatcher field.

According to the table here: 
http://code.google.com/p/google-gin/wiki/GuiceCompatibility
this feature is available.

And according to the documentation here:
http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/Injector.html#injectMembers(java.lang.Object)
it should just do exactly what you need!

Let me know if it works.

Regards

On Sep 13, 10:44 am, Asfak <[email protected]> wrote:
> Hello Friendz,
>
> I am in a situation where someone might be already in. I am using GWTP
> in my application. GWTP is using GIN as a client side
> dependency injection. GWTP also uses Dispatcher mechanism for sending
> request to server side.
>
> Now, There are some classes (PRESENTERS) which is injected by GWTP, I
> have some other classes which are created runtime without injection
> that means using "new" keywork. Let's have an example :
>
> // Injected
> class Dispatcher {
>
> }
>
> // Injected
> Class A {
>         @Inject // I can do this and access the disp without any hurdle.
>         Dispatcher disp;
>
> }
>
> // Created using "new" keywork
> class B {
>         //@Inject I can't do this because of B is not an injected class.
> Correct me if I am wrong here
>         Dispatcher disp;
>
> }
>
> So, I need to access Injected class in non injected classes. You might
> think I havn't tried GWT.Create(Injector.class) method. I have tried
> that and I am able to get that object in non inected classes but the
> object Dispatcher is something different it increments(adds) "/
> dispatch/" to its base url. That means i need to have the same object
> which GWTP internally using. And GWTP creates the GIN INJECTOR at the
> entry point.
>
> One solution is to put the same GIN INJECTOR to client side session
> (Static Hashmap) and use it in non injected classes (I have also tried
> this solution and it is working like charm).
>
> I need more perfect solution which can work.
>
> Thank you in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to