【问题标题】:GWT Editor - assignable to the raw Editor type, but a type parameterization is requiredGWT 编辑器 - 可分配给原始编辑器类型,但需要类型参数化
【发布时间】:2014-03-30 11:50:11
【问题描述】:

我正在尝试使用 GWT 中的编辑器框架,以便我可以让多个编辑器编辑同一个 bean(每个编辑器编辑一个不相交的字段子集)。

这大概是我所拥有的:

class EventEditor implements Editor<MajorEvent> {

    // Dispatch to a sub editor. 
    // Later there will be multiple such sub editors with different types,
    // but all implementing Editor<MajorEvent>.

    @Path("")
    public GenSubEditor genSubEditor() {
        return genPresenter.getView().getSubEditor();
    }
}

public class GenSubEditor implements Editor<MajorEvent> {

    Editor<String> nameEditor() {
        return endDate;
    }
}

这是 GWT 编译器给我的错误:

The type `GenSubEditor` is assignable to the raw Editor type, but a type parameterization is required.

如果我在 genSubEditor 方法中将 GenSubEditor 替换为 Editor&lt;MajorEvent&gt;,编译器不会抱怨。但是似乎驱动程序生成器没有解析我的子编辑器,并且永远找不到nameEditor。所以这不是一个解决方案,或者这意味着我做错了什么。

希望有人可以提供帮助。我没有提供 SSCCE,因为我实际上不知道如何创建存根 gwt 演示者/视图,但如果有人告诉我如何做,我会很高兴。

【问题讨论】:

  • nameEditor 在这里很可疑:生成器不能从Editor&lt;String&gt; 做很多事情。你可能想要一个LeafValueEditor&lt;String&gt;Editor&lt;String&gt; 的任何子类型,它可以有子编辑器(带有@Path(""))。恐怕这并不能解决你的问题。
  • 你是对的,谢谢。我用具体类型替换了返回类型,但这并没有解决问题。是不是我的所有子编辑器也需要一个驱动程序接口?

标签: gwt editor


【解决方案1】:

我相信这是一个 GWT 错误。 GWT 编译器不会读取非静态内部类的泛型类型。 在这种情况下,它知道GenSubEditor 实现了Editor,但无法读取其MajorEvent 参数类型。

尝试将GenSubEditor 设为static 类。 如果您使用任何引用,请记住删除对外部类实例的所有引用。

我将尝试提交有关此问题的错误报告。

【讨论】:

    猜你喜欢
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多