質問をする前に、コンテキストについて簡単に説明します。ui実装を別のクラスに「アウトソーシング」するWidgetクラスがあります(以下のように):
public class SimpleFilmWidget extends Composite implements FilmActivityControl {
public static interface Ui {
Panel getMainPanel();
VoteWidget getVotePanel();
InlineLabel getHaveNotSeenLabel();
//...
}
実際のウィジェットクラスは、Uiクラスインスタンスを使用して特定のサブフィールドウィジェット/要素への参照を取得できます。
Ui ui;
public SimpleFilmWidget() {
this(new DefaultUi());
}
public SimpleFilmWidget(Ui customUi) {
assert customUi != null : "UI should not be null!!!";
ui = customUi;
initWidget(ui.getMainPanel());
}
UiFactoryを使用して別の複雑なサブウィジェットを作成するUiBinderを使用して実際のUI実装を提供しました
class DefaultUi implements Ui {
//...
@UiFactory
protected VoteWidget createVoteWidget(){
return new VoteWidget(msg){
@Override
protected SetVoteEvent onSetVote(Star star, boolean fireEvents) {
return clientWidget.onSetVote(super.onSetVote(star, fireEvents));
}
};
}
そして、問題は次のとおりです。DefaultUiのサブクラスを提供すると、UiBinderパーサーを混乱させないように、UiFactoryメソッドをサブクラスでオーバーライドできますか?
編集:
uibinderは両方のメソッド(オーバーライドと上書き)を認識し、同じタイプの2つのuifactoryと混同されるため、UiFactoryメソッドをオーバーライドしないでください。[ERROR] Duplicate factory in class SimpleFilmWidget.DefaultUi for type VoteWidget