This also works! Thanks very much for your help!
Bye Henry On Nov 10, 8:47 pm, Jeff Larsen <larse...@gmail.com> wrote: > you could aways wrap the bundle in an implementation. > > interface BundleWrapper{ > DefaultResources getResources(); > > } > > class BundleWrapperGoodBye implements BundleWrapper{ > > DefaultResources getResources(){ > return GWT.create(GoodByeResources.class); > } > > class BundleWrapperHello implements BundleWrapper{ > > DefaultResources getResources(){ > > return GWT.create(HelloResources.class); > } > > } > > Then just use bundleWrapper everywhere to get access to your client > bundle and then you can do a <replace-with inside the module.xml based > on what you need. > > } > > On Nov 10, 10:15 am, Thalles <henry.rotz...@googlemail.com> wrote: > > > Hello Jeff, > > > thanks for your reply! > > > Actually, I wanted to utilize deferred binding to prevent these kind > > of code. > > Meaning, when I need to implement a new Resource class, I just need to > > add some configuration in the Module.gwt.xml, not in the actual code. > > > I got it to work with GIN, but deferred binding would be better > > though. > > > Here is my GIN module class (DefaultResources being the former > > MyResources): > > public class MapModule extends AbstractGinModule > > { > > @Override > > protected void configure() > > { > > bind(DefaultResources.class).to(GoodByeResources.class); > > } > > > } > > > And that is my GIN injector: > > @GinModules({MapModule.class}) > > public interface MapInjector extends Ginjector > > { > > public DefaultResources getMyResources(); > > > } > > > When I use DefaultResources now, it is automatically exchanged with > > the GoodByeResources. > > When I need another implementation, I just need to change it in the > > GIN Module class. > > > Bye Thalles > > > On Nov 9, 7:03 pm, Jeff Larsen <larse...@gmail.com> wrote: > > > > The easiest way would be to do this with GIN and a provider method. > > > > I'm not sure what the <when-property-is name="alerter" > > > value="goodbye">, so I could be off base here, but here is a way to do > > > it. > > > > @Inject > > > @Provides > > > public MyResources getMyResources(MyResources hello, GoodByeResources > > > goodBye, Alerter alerter){ > > > if(alerter.equals("hello")){ > > > return hello; > > > }else if(alerter.equals("goodbye")){ > > > return goodBye; > > > } > > > > } > > > > Also, MyResources needs to extend ClientBundle, and then by extendsion > > > GoodByResources automatically does. > > > > Then you can just @Inject MyResources and it will make the decsion as > > > to which resource bundle to return. > > > > On Nov 9, 11:13 am, Thalles <henry.rotz...@googlemail.com> wrote: > > > > > Hello group, > > > > > I've just got a quick question. Is it possible to do deferred binding > > > > with interfaces? > > > > Background: I would like to change the client bundle or constants > > > > interfaces, depending on the user. > > > > The problem is, that the client bundle or constants implementation has > > > > to be an interface itself. > > > > > I've tried to implement it, but it always says "Deferred binding > > > > result type <classname> should not be abstract" > > > > > This is my general class, that should be replaced: > > > > public interface MyResources > > > > { > > > > public static final MyResources INSTANCE = > > > > GWT.create(MyResources.class); > > > > > CssResource css(); > > > > TextResource getSynchronousTextResource(); > > > > ExternalTextResource getAsynchronousTextResource(); > > > > ImageResource getDLRLogo(); > > > > > } > > > > > Here is one of implementations > > > > public interface GoodByeResources extends ClientBundle, MyResources { > > > > public static final GoodByeResources INSTANCE = > > > > GWT.create(GoodByeResources.class); > > > > > @Source("files/test.css") > > > > CssResource css(); > > > > > @Source("files/test1.txt") > > > > TextResource getSynchronousTextResource(); > > > > > @Source("files/test2.txt") > > > > ExternalTextResource getAsynchronousTextResource(); > > > > > @Source("files/dlk.jpeg") > > > > ImageResource getDLKLogo(); > > > > > } > > > > > Here is a usage example: > > > > ImageWindow cmdw = new ImageWindow(myConstants.caption(), > > > > MyResources.INSTANCE.getDLKLogo()); > > > > > And this is my configuration: > > > > <replace-with class="gwt.map.client.constantstest.HelloResources"> > > > > <when-type-is class=gwt.map.client.constantstest.MyResources"/> > > > > <when-property-is name="alerter" value="hello"/> > > > > </replace-with> > > > > > <replace-with class="gwt.map.client.constantstest.GoodByeResources"> > > > > <when-type-is class="gwt.map.client.constantstest.MyResources"/> > > > > <when-property-is name="alerter" value="goodbye"/> > > > > </replace-with> > > > > > Is there any way, I could do this? Maybe a concrete class with an > > > > inner interface? > > > > Can I inject interfaces with GIN? > > > > > Thanks in advance! > > > > > Bye Thalles -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.