gpt4 book ai didi

java - GWT编辑器框架,如何实现编辑器的有效复用

转载 作者:行者123 更新时间:2023-12-02 07:48:48 24 4
gpt4 key购买 nike

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

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

BusinessUnitField businessUnit;

OperationCodeField operationCode;

OperationNumber operationNumber;

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

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

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 会提示,因为它说在生成委托(delegate)时,没有以类 ExampleTrans02Header 作为父级的 IdentityPanel_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
}

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

那么问题来了,这个案例还有其他的实现方式吗?我想知道这应该是一个非常常见的用例,但我找不到太多有关它的信息。

顺便说一句,我可能会说我是编辑器框架的新手,所以也许我解释了一些错误的东西,如果您能给我指明正确的方向,我将不胜感激。

问候,丹尼尔

最佳答案

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

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

关于java - GWT编辑器框架,如何实现编辑器的有效复用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10484003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com