1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    0
    sundoggie is on a distinguished road

      0  

    Default possible to Extend a GXT 3.0 Widget, then use uiBinder?

    possible to Extend a GXT 3.0 Widget, then use uiBinder?


    I am extending the GXT Window widget, to build a custom dialog, which works just fine. I'm extending Window, because Dialog really only supports a set of predefined buttons, and I want a resusable Widget class.

    I'd like to use UiBinder, and define the layout in the xml file, instead of creating it all through Java code. Does not seem possible though, because the UiBinder support is in the GWT Composite class (subclass of Widget), but the GXT 3.0 Window widget is a subclass of Widget (not Composite). So I can't write a statement like:

    initWidget (uiBinder.createAndBindUi (this)); //initWidget inherits from Composite, not Widget

    It's not the end of the world, but would be cleaner if I could use UiBinder to define the layout.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    88
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    UiBinder does *not* depend on Composite. You can use it anywhere you can use a widget (assuming you are building Widgets in your ui.xml file).

    The call
    Code:
    uiBinder.createAndBindUi(this)
    returns a Widget - you can use this anywhere you would normally use a widget. In a Window, you could use setWidget, in a class that just implements IsWidget, you could keep a reference to it and return it from the asWidget() method. In fact, it isn't even required that you keep a reference at all - if you put a ui:field on the root widget and have a field in your java class for it.


    Uses ui:field on root widget in ui.xml:
    http://www.sencha.com/examples/#Exam...%28uibinder%29

    Keeps value of createAndBind and returns it
    http://www.sencha.com/examples/#Exam...%28uibinder%29

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    0
    sundoggie is on a distinguished road

      0  

    Default


    thanks, that works perfect.

    One more related question....the GXT Window widget has a ButtonBar, and from the code side, it's easy to just add a button by writing: buttonBar.add(widget);

    Is that possible in uiBinder, or do buttons in the ui.xml file just go there. Looking the HelloWindowUiBinder example right now, seems like the Close button just magically winds up right justified in the window, not sure if it's in the button bar, or not, but there's nothing in the example ui.xml that would specify that.

Thread Participants: 1