Thank you for these explanations, I think I begin to understand GIN. .. and I'll read the Guice tutorials :-) (or may be :-( yet another tuto...)
Yves PS to GIN team : please make GIN simple to understand for those who don't know Guice and are just trying to improve their client code. I only came to GIN because it is used in some MVP explanations. On 28 juin, 09:00, PhilBeaudoin <[email protected]> wrote: > Thomas gives very good advice, although I personally neverusethe > @ImplementedBy annotation (not entirely sure why...). > > To complement his answer, if you're interested in saving the > "addClickHandler" call you may want to take a look at UiBinder the > @UiHandler annotation. > > On Jun 27, 3:41 pm, Thomas Broyer <[email protected]> wrote: > > > On 27 juin, 19:39, yves <[email protected]> wrote: > > > > Olivier, > > > > Thanks for the link. > > > > If I try to summarize my problem : Which are the conventions that are > > > implicitly used byGINto bind classes ? > > > > I've already seen gwt-presenter, but it didn't helped me to understand > > > how to transform my code to such code : > > > > public class AppModule extends AbstractGinModule { > > > > @Override > > > protected void configure() { > > > > bind(EventBus.class).to(DefaultEventBus.class); > > > > bind(MainPresenter.Display.class).to(MainWidget.class); > > > > bind(MenuPresenter.Display.class).to(MenuWidget.class); > > > > bind(IssueEditPresenter.Display.class).to(IssueEditWidget.class); > > > > bind(IssueDisplayPresenter.Display.class).to(IssueDisplayWidget.class); > > > If you control all of those classes, and they only exist as an > > interface+implementation class for testing purpose, then I'd rather > > annotate the interfaces with @ImplementedBy, e.g. > > �...@implementedby(MainWidget.class) > > public interface Display { ... } > > That way,GINwill automaticallyuseMainWidget as if you wrote the > > bind().to(); and in case you want to inject some other implementation > > (e.g. in some complex tests), you canusebind().to() without risking > > a "duplicate binding". > > > > Is there any doc explaining what is behind the scene with all these > > > "bind().to()" calls ? > > > > In my example, if I write something like > > > > bind(SearchPresenter.Display.class).to(someWidget.class); > > > > is it equivalent to > > > > display = d; > > > display.getSearchButton().addClickHandler(new > > > ClickHandler() { > > > > @Override > > > public void onClick(ClickEvent event) { > > > doSearch(event); > > > } > > > > }); > > > > and how to tellGINthat I need to call doSearch() ? > > > No!GINis only about dependency injection, i.e. it saves you the > > "new", and nothing else. > > With the above bind().to() and an @Inject annotation on the > > bind(Display) method, then whenGINis asked to instantiate a > > SearchPresenter (i.e. when you do not write the "new" yourself) it'll > > automatically instantiate a SomeWidget and call bind() with it as an > > argument (and when instantiating the SomeWidget, it'll automatically > > instantiate the required dependencies and inject them to @Inject- > > annotated constructor, fields and methods). > > > Maybe you should look for Guice tutorials to better understand what > > dependency injection is, and how to configure it with Guice. -- 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.
