0
我想爲我的複合表單使用基類,而不是直接從複合本身繼承。當我這樣做時,GWT設計師就會在這些子類上嘔吐。使用我自己的複合基類時GWT設計器的問題
這裏是我的基類:
package com.mycompany.project.client.panels;
import com.google.gwt.user.client.ui.Composite;
import com.mycompany.project.client.PanelNotifyCallback;
public class PanelBase extends Composite
{
protected PanelNotifyCallback NextButtonNotify = null;
protected PanelBase THIS = this;
public void setNextButtonNotify(PanelNotifyCallback nextButtonNotify)
{
NextButtonNotify = nextButtonNotify;
}
}
這裏是一個子類:
package com.mycompany.project.client.panels.p2;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.DoubleBox;
import com.mycompany.project.client.panels.PanelBase;
public class Panel2 extends PanelBase
{
public Panel2()
{
AbsolutePanel absolutePanel = new AbsolutePanel();
initWidget(absolutePanel);
absolutePanel.setSize("472px", "227px");
Label lblPanel = new Label("Panel2");
lblPanel.setStyleName("gwt-Label_Panel1");
absolutePanel.add(lblPanel, 193, 88);
lblPanel.setSize("67px", "23px");
Button btnNext = new Button("Next");
btnNext.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
// NextButtonNotify.Notify(THIS);
}
});
absolutePanel.add(btnNext, 196, 166);
Label lblPrice = new Label("Price:");
absolutePanel.add(lblPrice, 35, 37);
DoubleBox doubleBoxPirce = new DoubleBox();
doubleBoxPirce.setName("PriceBox");
absolutePanel.add(doubleBoxPirce, 75, 25);
}
}
這裏是當我打開設計視圖panel2.java發生了什麼
Exception during 'super' constructor evaluation
An exception happened during evaluation of constructor PanelBase() using arguments {}.
java.lang.AssertionError: This UIObject's element is not set; you may be missing a call to either Composite.initWidget() or UIObject.setElement()
at com.google.gwt.user.client.ui.UIObject.getElement(UIObject.java:556)
at com.mycompany.project.client.panels.PanelBase$$EnhancerByCGLIB$$9c1b2ca8.CGLIB$getElement$30(<generated>)
at com.mycompany.project.client.panels.PanelBase$$EnhancerByCGLIB$$9c1b2ca8$$FastClassByCGLIB$$1a67578f.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
我可以做我自己的基礎班,還有設計師的工作嗎?如果是這樣,什麼是錯的?這是一個相當簡單的設置。從長遠來看,我也想創建一些抽象基類。
我可以打開基類PanelBase的設計器視圖。