多くの場合、異なる DTO に共通する一連のプロパティを編集する同じパネルがあります。したがって、このパネルを一度だけ定義して再利用したいので、そのうちの 1 つに対して次の実装を思い付きました。
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;
........
}
これをコンパイルしようとすると、Delegate を生成するときに親としてクラス ExampleTrans02Header を持つ IdentificationPanel_businessUnit_Context クラスのコンストラクターがないと言われたため、GWT は不平を言います。
次のように IdentificationPanel を拡張することで、問題を解決できるかもしれません。
public class ExampleTrans01Identification extends IdentificationPanel<ExampleTrans01Header> {
// Nothing interesting to do here
}
public class ExampleTrans02Identification extends IdentificationPanel<ExampleTrans02Header> {
// Nothing interesting to do here
}
そして、パラメータ化されたクラスの代わりにこのクラスを使用しますが、これらのクラスには他の用途がないため、その解決策は少し厄介なようです。
問題は、このケースを実装する他の方法はありますか? これは非常に一般的なユースケースであるべきだと思っていましたが、それに関する情報はあまり見つかりませんでした。
余談ですが、私は Editor Framework を初めて使用するので、何か間違ったことを解釈していたのかもしれません。正しい方向に向けていただければ幸いです。
よろしく、ダニエル