I’m developing a web app for different formfactors. Each has its own client factory to create formfactor dependent views. Everythings works fine so far but I’m stuck when it comes to the Editor Framework.
To make use of the framework I have to declare a marker interface like so:
interface Driver extends SimpleBeanEditorDriver<User, UserEditor> {}
Since this happens in my formfactor agnostic activity I want the type UserEditor to refer to the actual implementation based on the formfactor, i.e. UserEditorPhone, UserEditorTablet, UserEditorYouNameIt.
To no avail I tried using deferred binding in module.gwt.xml:
<replace-with class="com.example.client.desktop.UserEditorDesktop">
<when-type-is class="com.example.client.view.UserEditor"/>
</replace-with>
Any ideas on what I’m missing and how to avoid having a one-to-one-relationship between formfactors and UserEditor-activities?
You’ll want your formfactor-agnostic activity to only know about
SimpleBeanEditorDriver<User, ?>, and move theDriverinterface into each one ofUserEditorDesktop,UserEditorTableandUserEditorPhone.The activity will then ask a formfact-dependent object (e.g. its view, if you use MVP and the activity is the presenter) for an instance of the editor driver rather than using
GWT.create()directly.(I can give code sample if you detail how your code is organized: are you using MVP? is the editor your view? how’s it instantiated? etc.)