GWT中的自定义TabLayoutPanel
我正在尝试创建我的自定义GWT中的自定义TabLayoutPanel,gwt,uibinder,gwt2,Gwt,Uibinder,Gwt2,我正在尝试创建我的自定义TabLayoutPanel扩展,我的代码如下: public class ExpandableTabLayoutPanel extends TabLayoutPanel { @UiConstructor public ExpandableTabLayoutPanel(double barHeight, Unit barUnit) { super(barHeight, barUnit); addExpandableBeha
TabLayoutPanel
扩展,我的代码如下:
public class ExpandableTabLayoutPanel extends TabLayoutPanel {
@UiConstructor
public ExpandableTabLayoutPanel(double barHeight, Unit barUnit) {
super(barHeight, barUnit);
addExpandableBehaviour();
}
private addExpandableBehaviour(){
//...
}
}
这里我从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>
当我禁用@UiConstructor
时,我得到了更奇怪的错误:
[ERROR] [gwtreproduce] - Errors in 'generated://E6338B946DFB2D28988DA492134093C7/reproduce/client/TestView_TestViewUiBinderImpl.java' : [ERROR] [gwtreproduce] - Line 33: Type mismatch: cannot convert from TabLayoutPanel to ExpandableTabLayoutPanel
扩展TabLayoutPanel有什么不对
附带问题:
TabLayoutPanel
constructor不带@UiConstructor注释,并且可以在UiBinder中使用(UiBinder如何知道调用哪个构造函数)?对于您,附带问题:您必须在小部件的UiField注释中添加(provided=true)。然后在代码中,在createAndBindUi()调用之前,自己设置实例,如下所示:
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));
}
}
类whoo扩展复合{
/*使用“提供”,UiBinder不调用任何构造函数*/
@UiField(提供的=真)
最后的大福;
接口whoouibinder扩展
UiBinder{}
专用静态WhooUIBinder uiBinder=
create(whoouibinder.class);
公共Whoo(){
//在createAndBindUi调用之前初始化“提供”
foo=新的伟大(字符串条,int-pouet);
initWidget(uiBinder.createAndBindUi(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));
}
}