GWT does this out of the box using the delayed snap function
When compiling a GWT application, the compiler actually generates different versions of the code for different browsers. this is done automatically out of the box with GWT components that take care of different browser details.
This feature can be extended to arbitrary compilation of the product based on user properties. here's a simplified example: suppose you have different definitions of definitions for a regular and a detailed view
public abstract class AbstractView { ....} public abstract class NormalView extends AbstractView { ... } public abstract class DetailedView extends AbstractView { ....}
you can create a module definition that will generate two different versions: one with the NormalView class NormalView other using DetailedView (in your gwt.xml file)
<define-property name="customMode" values="normal,detailed" /> <replace-with class="com.example.NormalView"> <when-type-is class="com.example.AbstractView" /> <when-property-is name="customMode" value="normal" /> </replace-with> <replace-with class="com.example.DetailedView"> <when-type-is class="com.example.AbstractView" /> <when-property-is name="customMode" value="detailed" /> </replace-with>
using
AbstractView view = GWT.create(AbstractView.class);
will provide the appropriate instance at runtime.
It is for you to encapsulate your client code in specific classes and expose common interfaces for different implementations.
You will also need to select the appropriate compiled version according to viewing the current client (for this you can use jsp.)
please do not accept the above code samples as tested, there may be problems with the syntax, it is just intended to convey a general idea
The JSP server is an ideal environment for hosting a GWT application, you can use the requestfactory mechanism for easy communication between the client and the server.
obviously there is a learning curve here, IMO's official documentation is a good place to start.