Search code examples
javagwtuibinder

UiBinder: Can UiFactory method be overriden?


Before asking a question i will shortly describe the context. I have a Widget class which "outsources" ui implementation to a separate class (sth like below):

public class SimpleFilmWidget extends Composite implements FilmActivityControl {

    public static interface Ui {

        Panel getMainPanel();

        VoteWidget getVotePanel();

        InlineLabel getHaveNotSeenLabel();

        //...
    }

The actual widget class can get references to specific subfield widget/elements with use of the Ui class instance:

    Ui ui;

    public SimpleFilmWidget() {
        this(new DefaultUi());
    }

    public SimpleFilmWidget(Ui customUi) {

        assert customUi != null : "UI should not be null!!!";

        ui = customUi;

        initWidget(ui.getMainPanel());
    }

I provided the actual UI implementation with UiBinder that uses UiFactory for creation of another one complicated subwidget

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));
            }
        };
    }

And the question is: When I provide the subclass of DefaultUi can the UiFactory method be overriden in a subclass not confusing UiBinder parser?

EDIT:

UiFactory method should not be overriden as uibinder sees both methods (the overridden and the overwriting) and becomes confused with two uifactories for the same type: [ERROR] Duplicate factory in class SimpleFilmWidget.DefaultUi for type VoteWidget


Solution

  • Conclusion:

    UiFactory method should not be overriden as uibinder sees both methods (the overridden and the overwriting) and becomes confused with two uifactories for the same type: [ERROR] Duplicate factory in class SimpleFilmWidget.DefaultUi for type VoteWidget.

    from comment to @Thomas Broyer: I suspect, it then calls the superclass'es UiFactory annotated method which is not what I want it to do. I left this issue, as workaround attitude is sufficing to me in this case.

    Thanks for Your interest anyway.