Search code examples
javaxmlgwtgxtuibinder

How to describe GXT Window from UiBinder?


I have a simple gxt window:

public class MainWindow extends Window {
    public MainWindow() {
        Label test = new Label("Test");
        add(test);
    }
}

And I want to describe the same window from UiBinder. This code work perfectly:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:gxt="urn:import:com.extjs.gxt.ui.client.widget">
    <gxt:Window>
    </gxt:Window>
</ui:UiBinder>

But when I add <gxt:Label>Test</gxt:Label> in gxt:Window element I have error:

[ERROR] Found unexpected child element Element <gxt:Label>

What I do wrong? What expected in Window element?


Solution

  • Ext GWT 2.x doesn't support UiBinder (the reason being the absence of public API to create custom element parsers in GWT: http://code.google.com/p/google-web-toolkit/issues/detail?id=4461).

    You can add a component gxt:Windows but that's it, you can't add child elements under gxt:Window, since there's no element parser for any of the gxt:Window superclasses. GWT's Panels extend GWT's HasWidgets and there's an element parser for them: HasWidgetsParser, which calls add() for each child element.

    It's possible to workaround this and I guess that's what they've done for Ext GWT 3 beta since it claims "full UiBinder support", so you can try that.