【问题标题】:GWT Editor Framework, how to implement an effective reuse of the editorGWT Editor Framework,如何实现编辑器的有效复用
【发布时间】:2012-05-07 14:39:06
【问题描述】:

在许多情况下,我有相同的面板来编辑不同 DTO 共有的一组属性。 所以我希望这个面板只定义一次并重用,所以我为其中一个想出了以下实现:

public class IdentificationPanel<M> extends Panel implements Editor<M> {

   BusinessUnitField businessUnit;

   OperationCodeField operationCode;

   OperationNumber operationNumber;

   ...........
}

因此,我将根据需要编辑的模型使用具有不同 DTO 的 IdentificationPanel。 例如我有:

public class ExampleTrans01 extends ModelDTO {

    private ExampleTrans01Header header;

    .......
}

public class ExampleTrans02 extends ModelDTO {

   private ExampleTrans02Header header;

   .....
}

public class ExampleTrans01Header extends ModelDTO {
   private Integer businessUnit;

   private String operationCode;

   private Long operationNumber;

   .......
   // Setters & Getters
}

public class ExampleTrans02Header extends ModelDTO {
   private Integer businessUnit;

   private String operationCode;

   private Long operationNumber;

   .......
   // Setters & Getters
}

因此,在我需要编辑的 2 个类的编辑器的实现中,我将拥有:

public class ExampleTrans01Editor extends Panel implements Editor<ExampleTrans01> {

   @Path("header")
   IdentificationPanel<ExampleTrans01Header> identification;

   .......
}

public class ExampleTrans02Editor extends Panel implements Editor<ExampleTrans02> {

   @Path("header")
   IdentificationPanel<ExampleTrans02Header> identification;

   ........
}

当我尝试编译它时,GWT 抱怨,因为它说在生成委托时没有以类 ExampleTrans02Header 作为父类的 IdentificationPanel_businessUnit_Context 类的构造函数。

我知道我可以通过扩展 IdentificationPanel 来解决这个问题,例如:

public class ExampleTrans01Identification extends IdentificationPanel<ExampleTrans01Header> {
    // Nothing interesting to do here
}

public class ExampleTrans02Identification extends IdentificationPanel<ExampleTrans02Header> {
   // Nothing interesting to do here
}

然后使用这些类代替参数化,但这种解决方案似乎有点讨厌,因为这些类不会有任何其他用途。

所以问题是,有没有其他方法可以实现这个案例?我想知道这应该是一个非常常见的用例,但我找不到太多关于它的信息。

在旁注中,我可能会说我是编辑器框架的新手,所以也许我解释错了,如果你能把我引向正确的方向,我将不胜感激。

问候, 丹尼尔

【问题讨论】:

    标签: java gwt gwt-editors


    【解决方案1】:

    这是一个已知问题,没有其他已知的解决方法。

    http://code.google.com/p/google-web-toolkit/issues/detail?id=6016

    【讨论】:

    • 感谢您的回答,Thomas,希望可以尽快解决此问题!
    • 应该包含在 GWT 2.5 中,在季度末之前发布(阅读:及时 Google I/O)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多