Search code examples
gwtuibinder

GWT UiBinder: How to make a custom AbsolutePanel which uses the "at" element?


Trying to extend AbsolutePanel, my UiBinder won't allow the <g:at> element which is normally ok for straight AbsolutePanels. How do I make my AbsolutePanel subclass able to use the <g:at> element? And more generally, can I make custom UiBinder keywords for my own custom Widgets like "at", "west", "layer" etc.?


Solution

  • You can use @UiChild to declare special functions in your widgets accessible in UiBinders.

    for example,

    class MyPanel extends AbsolutePanel {
    
        @UiChild
        public void addAt(Widget w, String parameter1, String parameter2) {
             ....
    

    Then, in your uiBinder, you can say

    <custom:MyPanel>
        <custom:at parameter1="HI" parameter2="Anything you like!">
            <g:AnySingleWidget />
        </custom:at>
    </custom:MyPanel>
    

    See @UiChild at http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/uibinder/client/UiChild.html