gwt - Using Gin to Inject Multiple Views -


i'm attempting put multi-project application, wherein 1 of sub-projects has multiple views single presenter. using gin inject views presenters.

the sub-project contains presenter , 2 different views. have 2 separate gin modules, each binding 1 of views view interface.

as per thomas broyer's suggestion on answer this post, ginjectors wrapped in "holder" class calls gwt.create on particular ginjector. appropriate holder configured in gwt.xml file using replace-with statement.

when run project in dev mode, see alternate view appear expect to. however, when compile project, still default view. also, 6 permutations (i expect more on account of replace-with logic), , not view expect in different scenarios.

here code illustrate.

subproject.gwt.xml contains this:

<replace-with class="com.example.ginjectordesktopholder">     <when-type-is class="com.example.ginjectorholder" />         </replace-with>  <replace-with class="com.example.ginjectortabletholder">     <when-type-is class="com.example.ginjectorholder" />     <when-property-is name="formfactor" value="tablet" /> </replace-with> 

the "formfactor" variable defined in gwt.xml copied verbatim gwt's mobilewebapp sample project.

the holder classes this:

public abstract class ginjectorholder {     public abstract ginjector getginjector(); } 


public class ginjectortabletholder extends ginjectorholder {     @override     public ginjector getginjector() {         return gwt.create(ginjectortablet.class);     }    } 


public class ginjectordesktopholder extends ginjectorholder {     @override     public ginjector getginjector() {         return gwt.create(ginjectordesktop.class);     } } 

my ginjectors this:

public interface myginjector {     myview getview();     eventbus geteventbus(); } 


@ginmodules({moduledesktop.class}) public interface ginjectordesktop extends ginjector, myginjector {} 


@ginmodules({moduletablet.class}) public interface ginjectortablet extends ginjector, myginjector {} 

my modules this:

public class moduledesktop extends abstractginmodule {     @override     protected void configure() {         bind(mypresenter.view.class).to(desktopview.class);     } } 


public class moduletablet extends abstractginmodule {     @override     protected void configure() {         bind(mypresenter.view.class).to(tabletview.class);     } } 

and finally, in presenter proxy, entry point particular sub-project, have line:

ginjectorholder holder = gwt.create(ginjectorholder.class); myginjector ginjector = holder.getginjector();       

as mentioned earlier, when run in dev mode , put in breakpoints, can see appropriate ginjectorholder created. formfactor.gwt.xml (linked above) provides switch using url param switch context you'd see. can formfactor=tablet in url , tablet ginjector holder created.

as mentioned in comments, removing line

<collapse-property name="formfactor" values="*"/> 

leads expected increase in number of permutations.

still, it's mysterious, why necessary, because should possible collapse properties - means, each browser has download more code, should still needs. bug.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -