WidgetMapGenerator in Vaadin 7

Hello All!

In Vaadin 6 I used to trim the list of components to be included in the widgetset by using CustomWidgetMapGenerator.
I was basically overriding getUsedPaintables to return short list of components (“Paintables”) that i was using within the application,
thus significantly reducing the compiled widgetset size.
Unfortunately there were several changes in Vaadin 7 affecting this, and the old method is not longer working.

Is there any other mechanism in the newest Vaadin 7, that accomplishes the same task?
The version I’m using now is 7.0.0beta7.

Thanks in advance!

Code splitting is currently broken in Vaadin 7 (
) - practically all the generated code goes into the main widgetset JavaScript file. When that is fixed, it might also help you.

The method that is currently the closest equivalent to getPaintables() is ConnectorBundleGenerator.getLoadStyle(connectorType) - I believe it can return null to omit a widget. The generator is activated in com/vaadin/Vaadin.gwt.xml .


I will then probably wait for the changes in this matter.

Best Regards!

Hello all,

If anyone is still interested in generating custom widgetset, it is now possible with vaadin 7.0.0-RC1.
It works by extending ConnectorBundleLoaderFactory class and implementing your own getConnectorsForWidgetset() method that returns list of connectors (Collection) to be included in the compiled widgetset.

Here is how it works for me:

  1. open the AppWidgetSet.gwt.xml of your app and add this somewhere between tags:

            class="com.vaadin.client.metadata.ConnectorBundleLoader" />
  1. Create class your.package.WidgetLoaderFactory that extends ConnectorBundleLoaderFactory and implements getConnectorsForWidgetset
    Here’s my example:

public class WidgetLoaderFactory extends com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory {
	protected Collection<JClassType> getConnectorsForWidgetset( 
		 	TreeLogger logger, TypeOracle typeOracle) 
		 	throws UnableToCompleteException {
		ArrayList<String> filterOutList = new ArrayList<String>(
                            /* here you can put all connectors that you're NOT going to use */
         //get list of all connectors
		Collection<JClassType> c = super.getConnectorsForWidgetset(logger, typeOracle);
         //filter out unneded ones
		c = filterOutTypes(c, filterOutList);
		return c;
	private Collection<JClassType> filterOutTypes(Collection<JClassType> all, ArrayList<String> removeClasses) {
		ArrayList<JClassType> list = new ArrayList<JClassType>();
		for (JClassType jct : all) {
			boolean exists = false;
			for (String f: removeClasses) {		
				if (jct.toString().toLowerCase().contains(f.toLowerCase()) == true) {
					exists = true;
			if (exists == false) {
		return list;
  1. be sure to include vaadin-compiler


you may want to remove it later from resulting WAR, or just use it for widgetset compilation only. In my case i remove it from WAR, as it breaks something.

  1. when you rebuild your entire project, your widgetset should be now smaller.

  2. if you’re interested in making widgetset even less heavy, I suggest also looking at gzip compression. you can get really good results (like making it 1/5 of original size)

Hope it helps

There is now also a
about this and an add-on that makes the process easier - see the tutorial page.

I would recommend starting with enabling gzip compression on the server (it always helps, whether you limit the set of eager widgets or not) and only then considering limiting the content of the widgetset if necessary.