com.vaadin.terminal.gwt.widgetsetutils
Class WidgetMapGenerator

java.lang.Object
  extended by com.google.gwt.core.ext.Generator
      extended by com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator
Direct Known Subclasses:
CustomWidgetMapGenerator, EagerWidgetMapGenerator, LazyWidgetMapGenerator

public class WidgetMapGenerator
extends com.google.gwt.core.ext.Generator

WidgetMapGenerator's are GWT generator to build WidgetMapImpl dynamically based on Connect annotations available in workspace. By modifying the generator it is possible to do some fine tuning for the generated widgetset (aka client side engine). The components to be included in the client side engine can modified be overriding #getUsedConnectors().

The generator also decides how the client side component implementations are loaded to the browser. The default generator is EagerWidgetMapGenerator that builds a monolithic client side engine that loads all widget implementation on application initialization. This has been the only option until Vaadin 6.4.

This generator uses the loadStyle hints from the Connect annotations. Depending on the Connect.LoadStyle used, the widget may be included in the initially loaded JavaScript, loaded when the application has started and there is no communication to server or lazy loaded when the implementation is absolutely needed.

The GWT module description file of the widgetset ( ...Widgetset.gwt.xml) can be used to define the WidgetMapGenarator. An example that defines this generator to be used:

 
 <generate-with
           class="com.vaadin.terminal.gwt.widgetsetutils.MyWidgetMapGenerator">
          <when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" />
 </generate-with>
 
 
 

Vaadin package also includes LazyWidgetMapGenerator, which is a good option if the transferred data should be minimized, and CustomWidgetMapGenerator for easy overriding of loading strategies.


Constructor Summary
WidgetMapGenerator()
           
 
Method Summary
 String generate(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.GeneratorContext context, String typeName)
           
protected  Connect.LoadStyle getLoadStyle(Class<? extends ServerConnector> connector)
          Returns true if the widget for given component will be lazy loaded by the client.
 
Methods inherited from class com.google.gwt.core.ext.Generator
escape
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WidgetMapGenerator

public WidgetMapGenerator()
Method Detail

generate

public String generate(com.google.gwt.core.ext.TreeLogger logger,
                       com.google.gwt.core.ext.GeneratorContext context,
                       String typeName)
                throws com.google.gwt.core.ext.UnableToCompleteException
Specified by:
generate in class com.google.gwt.core.ext.Generator
Throws:
com.google.gwt.core.ext.UnableToCompleteException

getLoadStyle

protected Connect.LoadStyle getLoadStyle(Class<? extends ServerConnector> connector)
Returns true if the widget for given component will be lazy loaded by the client. The default implementation reads the information from the Connect annotation.

The method can be overridden to optimize the widget loading mechanism. If the Widgetset is wanted to be optimized for a network with a high latency or for a one with a very fast throughput, it may be good to return false for every component.

Parameters:
connector -
Returns:
true iff the widget for given component should be lazy loaded by the client side engine


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.