我想實現一個自定義的TabLayoutPanel,當添加一個窗口小部件(通過自定義動作,如關閉標籤等)時,它會自動設置標籤本身。帶參數的GWT UiConstructor,類沒有適當的setter方法
我創建了一個CustomTabPanel.ui.xml以及一個CustomTabPanel.java。 UI設計只是嵌入一個TabLayoutPanel,代碼部分公開了我需要的一些功能。 我也有一個構造函數,它採用與TabLayoutPanel相同的兩個參數,我想在UI設計模式中傳遞,就像我對普通的TabLayoutPanel所做的一樣。 它看起來像這樣
public class CustomTabPanel extends Composite{
/* ... here all the uiBinder things
already written by my eclipse plugin */
@UiField(provided=true)
TabLayoutPanel tabPanel;
public @UiConstructor CustomTabPanel(double barHeight, Unit barUnit){
tabPanel = new TabLayoutPanl(barHeight, barUnit);
initWidget(uiBinder.creatAndBindUi(this));
}
我使用自定義組合構件在另一個.ui.xml
文件 但是,當我啓動,並在我的瀏覽器中測試Web應用程序,我得到以下錯誤:
Class CustomTabPanel has no appropriate setBarUnit() method. Element <my:ClosableTabPanel barHeight='2' barUnit='EM' ui:field='closablepanel'>
我按照http://code.google.com/intl/fr/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_a_widget上的說明進行操作。我想我已經錯過了一些東西,但是我不知道它是什麼。
此外,我嘗試通過創建派生的class ExtendedTabLayoutPanel extends TabLayoutPanel{...}
並使用參數實現構造函數來使用繼承。這給了我,在運行時,另一個錯誤:
Line xx: Type mismatch: cannot convert from TabLayoutPanel to ExtendedTabLayoutPanel
希望我很清楚......很快就讀到您!
一切工作正常,單位作爲第一個參數。 – 2011-03-08 08:22:17