Using GWT 2.4.0 I'm attempting to use deferred binding rules to substitute a uibinder template for another.
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.
public class ThemeOneUiBinderImpl {
@UiTemplate("ThemeOne.ui.xml")
interface ThemeOneUiBinder extends UiBinder<Widget, PageToTheme> {
}
private static ThemeOneUiBinder uiBinder = GWT.create(ThemeOneUiBinder.class);
public static UiBinder<Widget, PageToTheme> getImpl() {
return uiBinder;
}
}
Then I have a second class that is basically the same called ThemeTwoUiBinderImpl. My class references ThemeOneUiBinderImpl and calls getImpl().createAndBindUi(this)
And the following deferred binding rules
<replace-with class="package.ThemeTwoUiBinderImpl">
<when-type-is class="package.ThemeOneUiBinderImpl"/>
<when-property-is name="theme" value="theme2"/>
</replace-with>
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:
- Why isn't it working?
- 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?
- 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.
Thoughts? Solutions? Thanks!