在很多情况下,我有相同的面板编辑一组属性,这些属性是不同的DTO共有的。 所以我想有这样的面板只定义一次和重用,所以我想出了以下实施其中之一:GWT编辑器框架,如何实现编辑器的有效重用
public class IdentificationPanel<M> extends Panel implements Editor<M> {
BusinessUnitField businessUnit;
OperationCodeField operationCode;
OperationNumber operationNumber;
...........
}
所以我会用IdentificationPanel与根据我需要的型号不同的DTO编辑。 比如我有:
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抱怨,因为它说当IdentificationPanel_businessUnit_Context类生成Delegate时,没有类ExampleTrans02Header作为父类的构造函数。
我知道我也许摆脱问题通过扩展IdentificationPanel,如:
public class ExampleTrans01Identification extends IdentificationPanel<ExampleTrans01Header> {
// Nothing interesting to do here
}
public class ExampleTrans02Identification extends IdentificationPanel<ExampleTrans02Header> {
// Nothing interesting to do here
}
然后使用这个类来代替参数,但是这种解决方案似乎是有点讨厌,因为这些类不会有任何其他用途。
所以问题是,有没有其他的方式来实现这种情况?我想知道这应该是一个非常常见的用例,但我无法找到关于它的更多信息。
在旁注中,我可能会说我是编辑器框架的新手,所以也许我正在解释错误的东西,如果能让我走向正确的方向,我会很感激。
问候, 丹尼尔
感谢您的回答托马斯,希望这可以很快解决! –
应该包含在GWT 2.5中,在季度结束之前发布(阅读:适用于Google I/O) –