2013-03-19 51 views
3

我試圖在GWT中使用編輯器框架,以便可以讓多個編輯器編輯同一個bean(每個編輯器編輯一個不相交的字段子集)。GWT編輯器 - 可分配給原始編輯器類型,但需要類型參數化

這裏大概是我有:

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.

如果我通過Editor<MajorEvent>genSubEditor方法代替GenSubEditor,編譯器沒有按抱怨。但是,那麼似乎驅動程序生成器不會解析我的子編輯器並且從未找到nameEditor。所以這不是一個解決方案,或者它意味着我做了其他錯誤。

希望有人能幫忙。我沒有提供SSCCE,因爲我實際上不知道如何創建一個stub gwt主持人/視圖,但如果有人告訴我如何去做,我很樂意。

+0

'nameEditor'在這裏是可疑的:生成器不能從'Editor '做很多事情。你可能想要一個'LeafValueEditor '或者'Editor '的子類型,它可以有子編輯器(帶有@Path(「」)「)。雖然我害怕,但這並不能解決您的問題。 – 2013-03-19 17:10:36

+0

你是對的,謝謝。我用具體類型替換了返回類型,但它不能解決問題。難道我需要一個驅動界面來管理我所有的編輯器嗎? – ARRG 2013-03-20 08:17:47

回答

2

我相信這是一個GWT錯誤。 GWT編譯器不會讀取非靜態內部類的泛型類型。 在這種情況下,它知道GenSubEditor實現了Editor,但未能讀取其MajorEvent參數類型。

嘗試製作GenSubEditor a static類。 請記住刪除對外部類實例的所有引用,如果使用任何引用。

我會嘗試提交有關此問題的錯誤報告。