GXT3 - ColumnSelectionAppearance ClassCastException

时间:2014-06-18 14:11:30

标签: java gxt

我无法实现GridSelectionModel(使用CheckBoxSelectionModel作为灵感) 我想创建一个RadioSelectionModel,但是当我调用构造函数时,我有一个ClassCastException。 这是我的类结构(如果需要我放一些代码,但我不认为这是必要的)。我正在使用列表和子列表来显示类和嵌入类:

  • class RadioSelectionModel < M > extends GridSelectionModel< M >
    • interface RadioColumnAppearance < M >
  • class RadioColumnDefaultAppearance < M >
    • interface RadioColumnStyle extends CssResource, ColumnHeaderStyles, GridDataTableStyles
    • interface RadioColumnResources extends ClientBundle

RadioColumnAppearance通过gwt.xml文件链接到RadioColumnDefaultAppearance

<replace-with
    class="com.app.appearance.RadioColumnDefaultAppearance">
    <when-type-is
        class="com.app.grid.RadioSelectionModel.RadioColumnAppearance" />
</replace-with>

我碰巧发现ClassCastException是我打电话给GWT.create( RadioColumnAppearance.class )但我不知道到底是什么  问题以及我如何解决它

编辑:这是RadioColumnDefaultAppearance代码。我相信这个问题就在这里,因为我在调用GWT.create时只有异常。关于错误,这是我在浏览器控制台Uncaught java.lang.ClassCastException中收到的简单消息:

public class RadioColumnDefaultAppearance < M > implements CheckBoxColumnAppearance< M >
{

public interface RadioColumnStyle extends CheckBoxColumnStyle
{

}

public interface RadioColumnResources extends ClientBundle
{
    @Source( "/css/RadioColumn.css" )
    RadioColumnStyle style();

    @Source( "column.png" )
    @ImageOptions( repeatStyle = RepeatStyle.Vertical )
    ImageResource specialColumn();

    @Source( "column_checked.png" )
    @ImageOptions( repeatStyle = RepeatStyle.Vertical )
    ImageResource specialColumnSelected();
}

private final RadioColumnResources resources;
private final RadioColumnStyle style;

public RadioColumnDefaultAppearance()
{

    this( GWT.< RadioColumnResources > create( RadioColumnResources.class ) );
}

public RadioColumnDefaultAppearance( RadioColumnResources resources )
{
    this.resources = resources;

    this.style = this.resources.style();

    StyleInjectorHelper.ensureInjected( style, true );
}

public void renderRadio( Context context, M value, SafeHtmlBuilder sb )
{
    sb.appendHtmlConstant( "<div class='x-grid-row-checker'>&#160;</div>" );
}


}

1 个答案:

答案 0 :(得分:1)

您的RadioColumnDefaultAppearance未实现RadioColumnAppearance接口。如果要为接口定义默认实现,则该类必须实现该接口,否则无法将实现类的实例分配给接口引用。