0

For some inexplicable reason for me ,Gin does not works as i intend. Let me explain with little code.

Let say i have a formA

@Singleton
public class formA extends Composite

    private final MyGinjector ginjector;

    @Inject
    public formA(MyGinjector ginjector)
    {
      this.ginjector = ginjector;
      this.add(ginjector.getFormB());
      this.add(ginjector.getFormC());   
    }

here are and formB and formC (let assume formB and formC has similar code)

@Singleton
public class formB extends Composite
{
@Inject
public formB(MyGinjector ginjector)
{
  this.ginjector = ginjector;
..............
}
}

And the problem i has been facing is in some moment when i inject formA (ginjector.getFormA() return an instance of formA but with missing childWidgets meaning with no reference to formB and formC

What could be the problem? all forms are singleton ... probably i should not inject the ginjector like that?

Thanks

brakebg
  • 414
  • 3
  • 11
  • 24

1 Answers1

0

I believe gin does not support injecting the injector: gin groups discussion.

Is there any reason you try injecting injector instead od injecting dependencies directly?

You should just inject dependencies directly:

    @Inject
    public formA(FormB formB, FormC formC){
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • The same situation if i inject direct. The problem is weird because actually i m adding formB and formC as a widgets in formA which is A Compose, so after 2 or 3 calls instance of formA does not keep anymore widgets formB and formC .. .The image is simple.. formA keeps two panels (formB and formC) and when i get instance of formA i expect to see those panels but they are missing.. – brakebg Jun 14 '11 at 14:04