title: Using GWT Deferred Binding to replace uibinder template
body: <p>Using GWT 2.4.0 I'm attempting to use deferred binding rules to substitute a uibinder template for another.</p>
  
  <p>The way that I have come up with to do this is by creating a concrete class for each uibinder template that returns the instance of the uibinder.  Here is an example.</p>
  
  <pre><code>public class ThemeOneUiBinderImpl {
  
      @UiTemplate("ThemeOne.ui.xml")
          interface ThemeOneUiBinder extends UiBinder&lt;Widget, PageToTheme&gt; {
      }
  
      private static ThemeOneUiBinder uiBinder = GWT.create(ThemeOneUiBinder.class);
  
      public static UiBinder&lt;Widget, PageToTheme&gt; getImpl() {
          return uiBinder;
      }
  }
  </code></pre>
  
  <p>Then I have a second class that is basically the same called ThemeTwoUiBinderImpl.  My class references ThemeOneUiBinderImpl and calls getImpl().createAndBindUi(this)</p>
  
  <p>And the following deferred binding rules
      
      </p>
  
  <pre><code>&lt;replace-with class="package.ThemeTwoUiBinderImpl"&gt;
      &lt;when-type-is class="package.ThemeOneUiBinderImpl"/&gt;
      &lt;when-property-is name="theme" value="theme2"/&gt;
  &lt;/replace-with&gt;
  </code></pre>
  
  <p>With these rules in place, when I compile I see that the number of permutations doubles so it is doing something...  But when I load the page, the theme1 uibinder is still loading.  I have two issues:</p>
  
  <ol>
  <li>Why isn't it working?</li>
  <li>Why does the number of permutations double?  I thought that by setting the property to theme2, it would only compile permutations for theme2 but is it compiling for both?</li>
  <li>Am I using deferred binding how it is designed to be used?  I did evaluate using the Appearance Pattern which is similar to what I am doing but it seemed like total overkill for what I need to do and I already have the two custom uibinders written.  These components will not be reusable or extended.  The themes are just for simple custom headers.</li>
  </ol>
  
  <p>Thoughts? Solutions?  Thanks!</p>