0

I'm trying to create my custom TabLayoutPanel extension, my code is following:

public class ExpandableTabLayoutPanel extends TabLayoutPanel {

    @UiConstructor
    public ExpandableTabLayoutPanel(double barHeight, Unit barUnit) {
        super(barHeight, barUnit);
        addExpandableBehaviour();
    }

    private addExpandableBehaviour(){
      //...
    }
}

And here I invoke it from UIBinder:

<a:ExpandableTabLayoutPanel barHeight="20" barUnit="PX">
    <a:tab>
    <a:header>header</a:header>
        <a:AdvancedRichTextArea styleName="{style.area}" ui:field="area"/>
    </a:tab>
</a:ExpandableTabLayoutPanel>

(I was forced by error messages to use a:tab/a:header instead of g:tab/g:header even if I don't have tab and header defined in my a: package/workspace, but that's probably not the issue)

If @UiConstructor annotation is present over ExpandableTabLayoutPanel like in the listing, I'm getting strange error:

[ERROR] [gwtreproduce] - <a:ExpandableTabLayoutPanel barHeight='20' barUnit='PX'> missing required attribute(s): arg1 barHeight Element <a:ExpandableTabLayoutPanel barHeight='20' barUnit='PX'> (:13)

When I disable @UiConstructor, I'm getting even stranger error:

[ERROR] [gwtreproduce] - Errors in 'generated://E6338B946DFB2D28988DA492134093C7/reproduce/client/TestView_TestViewUiBinderImpl.java' :             [ERROR] [gwtreproduce] - Line 33: Type mismatch: cannot convert from TabLayoutPanel to ExpandableTabLayoutPanel 

What am I doing wrong with extending TabLayoutPanel?

And side question: how it is possible that TabLayoutPanel constructor isn't annotated with @UiConstructor and can be used in UiBinder (how UiBinder knows which constructor to invoke)?

Piotr Sobczyk
  • 6,443
  • 7
  • 47
  • 70
  • possible duplicate of [GWT ui.xml ; cannot convert docklayout panel to custom panel](http://stackoverflow.com/questions/11433805/gwt-ui-xml-cannot-convert-docklayout-panel-to-custom-panel) – Thomas Broyer Jul 18 '12 at 18:49

1 Answers1

0

for you side question : you have to add (provided=true) to the UiField annotation of your widget. Then in the code, set the instance yourself, before createAndBindUi() call like this :

class Whaoo extends Composite{

    /* with 'provided', UiBinder don't call any constructor */
    @UiField(provided = true)
    final Great foo;

    interface WhaooUiBinder extends
        UiBinder<Widget, Whaoo> {}

    private static WhaooUiBinder uiBinder = 
         GWT.create(WhaooUiBinder.class);

    public Whaoo() {

        // initialize "provided" before createAndBindUi call
        foo = new Great(String bar, int pouet); 

        initWidget(uiBinder.createAndBindUi(this));

    }
}
Arcadien
  • 2,258
  • 16
  • 26