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 view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/j3cq2JPEA6UJ.
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.