Friday, February 14, 2014

Re: Form factor support using GIN

Hi,

I have followed your approach but I have got error that MyGinjector should be annotated with GinModule. In your example you have not annotated MyGinjector.
Can you please help providing sample code fragment which works. I am developing an web application for Desktop, Tablet, Mobile platforms, I am kind of stuck.

Kind regards
Nava

On Monday, 7 January 2013 05:15:43 UTC, Alexandre Senecal wrote:
Thank you for this example, it was quite helpful! 
One small correction, the form factor specific Ginjectors should extend the MyGinjector interface as follows:


 
@GinModules(SharedGinModule.class, DesktopGinModule.class)
interface DesktopGinjector extends MyGinjector {
   // nothing special here; it's only used for the @GinModules annotation
}
@GinModules(SharedGinModule.class, TabletGinModule.class)
interface TabletGinjector extends MyGinjector { }
@GinModules(SharedGinModule.class, PhoneGinModule.class)
interface PhoneGinjector extends MyGinjector { }



On Sunday, 6 November 2011 09:58:07 UTC-5, Thomas Broyer wrote:
Deferred binding only occurs when you use GWT.create(). If you "new ViewFactory()", there's no reason you'll be given a TableViewFactory. GWT doesn't change Java's semantics.

What you have to do is to use a distinct Ginjector depending on the form factor, and you can re-use the same GinModule(s) for all the shared binding configurations, and add a specific GinModule per form factor. Unfortunately, you cannot use both a generate-with (GIN's Ginjector) and replace-with (chose the right Ginjector depending on form factor), so you'll have to use a replace-with rule on a "provider class" for you Ginjector:

interface MyGinjector extends Ginjector {
   // all your accessors
}
@GinModules(SharedGinModule.class, DesktopGinModule.class)
interface DesktopGinjector extends Ginjector {
   // nothing special here; it's only used for the @GinModules annotation
}
@GinModules(SharedGinModule.class, TabletGinModule.class)
interface TabletGinjector extends Ginjector { }
@GinModules(SharedGinModule.class, PhoneGinModule.class)
interface PhoneGinjector extends Ginjector { }

interface GinjectorProvider {
   MyGinjector get();
}
class DesktopGinjectorProvider implements GinjectorProvider {
   public MyGinjector get() { return GWT.create(DesktopGinjector.class); }
}
class TabletGinjectorProvider implements GinjectorProvider {
   public MyGinjector get() { return GWT.create(TabletGinjector.class); }
}
class PhoneGinjectorProvider implements GinjectorProvider {
   public MyGinjector get() { return GWT.create(PhoneGinjector.class); }
}

<replace-with class="...DesktopGinjectorProvider">
   <when-type-is class="...GinjectorProvider" />
   <when-property-is name="formfactor" value="desktop" />
</replace-with>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment