0

複合フォーム自体から直接継承するのではなく、複合フォームに基本クラスを使用したいと考えています。これを行うと、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 のデザイナー ビューを開くことができます。

4

1 に答える 1

0

原因、デザイナーが窒息する原因を突き止めました。

保護された PanelBase これは = これです。

その行。基本クラスで「this」ポインターのコピーを作成すると、サブクラスのデザイン タブを開こうとすると、デザイナーが吐き気を催します。コンストラクターでこの割り当てを行っても、それでも吐きます。

回避策はないと思います。サブクラス内のいくつかの匿名クラスで「this」ポインターを使用したかっただけです。基本クラスがこのリファレンスの適切なホルダーになると考えました。

于 2013-01-18T19:32:37.047 に答える