[英]GWT Editor Framework, how to implement an effective reuse of the editor
In many cases I have the same panel which edits a set of properties that are common to different DTOs. 在许多情况下,我有相同的面板,编辑一组不同DTO共有的属性。 So I want to have this panels defined only once and reuse so I came up with the following implementation for one of them:
所以我希望这个面板只定义一次并重复使用,所以我为其中一个想出了以下实现:
public class IdentificationPanel<M> extends Panel implements Editor<M> {
BusinessUnitField businessUnit;
OperationCodeField operationCode;
OperationNumber operationNumber;
...........
}
So I will use the IdentificationPanel with different DTOs depending on the Models I will need to edit. 所以我将使用不同DTO的IdentificationPanel,具体取决于我需要编辑的模型。 For example I have:
例如,我有:
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
}
So in the implementation of the editors for the 2 classes I need to edit I will have: 所以在我需要编辑的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;
........
}
When I try to compile this, GWT complains because it said that there is no constructor for the IdentificationPanel_businessUnit_Context class with the class ExampleTrans02Header as parent when it was generating the Delegate. 当我尝试编译它时,GWT抱怨,因为它表示在生成Delegate时,没有构造函数用于IdentificationPanel_businessUnit_Context类,并且ExampleTrans02Header类作为父类。
I know I maybe get rid of the problem by extending IdentificationPanel, like: 我知道我可以通过扩展IdentificationPanel解决问题,例如:
public class ExampleTrans01Identification extends IdentificationPanel<ExampleTrans01Header> {
// Nothing interesting to do here
}
public class ExampleTrans02Identification extends IdentificationPanel<ExampleTrans02Header> {
// Nothing interesting to do here
}
And then use this classes instead the parameterized, but that solution seems to be a little nasty because those classes will not have any other use. 然后使用这个类而不是参数化,但该解决方案似乎有点讨厌,因为这些类将没有任何其他用途。
So the question is, are there any other way of implement this case? 所以问题是,有没有其他方法来实现这种情况? I was wondering that this should be a very common use case, but I couldn't found much info about it.
我想知道这应该是一个非常常见的用例,但我找不到很多关于它的信息。
On a side note I may said that I new to Editor Framework so maybe I was interpreting something wrong, I will appreciated if you could put me in the right direction. 另外,我可能会说我是编辑框架的新手,所以也许我在解释错误的内容,如果你能把我放在正确的方向,我将不胜感激。
Regards, Daniel 问候,丹尼尔
This is a known issue and there's no other known workaround. 这是一个已知问题,没有其他已知的解决方法。
http://code.google.com/p/google-web-toolkit/issues/detail?id=6016 http://code.google.com/p/google-web-toolkit/issues/detail?id=6016
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.