4 Replies Latest reply: Feb 22, 2012 11:24 AM by David Hahn RSS

Problems with @Inject annotation

Rene Lenno Newbie

Hi,

 

I'm trying to use Errai in my GWT project. I'm a total newbie, so my question may be trivial but I really can't figure it out:

 

I have a GWT Project that is designed according to the MVP GWT example:

http://code.google.com/intl/en-US/webtoolkit/articles/mvp-architecture.html

 

I'm trying to replace the server-client communication bei Errai. The problem I have is that the Incetion only seems to work. On the @EntryPoint:

 

@EntryPoint

public class App {

 

    @Inject

    private Event<UserCustomRequest> userCustomRequest;

 

    @PostConstruct

    public void onModuleLoad() {

        new AppController(this).go(RootPanel.get());

    }

 

    public void response(@Observes UserCustomResponse event) {

         Window.alert("response");

    }

    [...]

}

 

This works fine, but if i try to use the @Inject annotation for my requests or responeses in other classes than the @EntryPoint, the injection seems to fail (in this case, userCustomRequest is null). Also the response method isn't called in any other class than the @EntryPoint class:

 

public class AnyPresenter implements Presenter {

     @Inject

     private Event<UserCustomRequest> userCustomRequest;

 

     public void response(@Observes UserCustomResponse event) {

          Window.alert("response");

     }

     [...]

}

 

 

Thanks for the help!