Vaadin 14 - Why on onAttach() is called twice on LoginOverLay?

Viewed 90

I have this code for a login view:

@SuppressWarnings("serial")
@Route(AppConst.LOGIN_PAGE)
@PageTitle("Login")
@Viewport(AppConst.VIEWPORT)
public final class LoginView extends LoginOverlay 
    implements BeforeEnterObserver, ComponentEventListener<AbstractLogin.LoginEvent>{
        
    public LoginView() {
        
        LoginI18n i18n = LoginI18n.createDefault();
        i18n.setHeader(new LoginI18n.Header());
        i18n.getHeader().setTitle("App");
        i18n.getHeader().setDescription("");
        i18n.setAdditionalInformation(null); 
        i18n.setForm(new LoginI18n.Form());
        i18n.getForm().setSubmit("Sign in");
        i18n.getForm().setTitle("Sign in");
        i18n.getForm().setUsername("Email");
        i18n.getForm().setPassword("Password");
        setI18n(i18n);
        setForgotPasswordButtonVisible(false);

        addLoginListener(this);
        
    }

    @Override
    protected void onAttach(AttachEvent attachEvent) {
        
        System.out.println("on attach called");
    }

    @Override
    public void onComponentEvent(LoginEvent event) {
        
        // do something
    }

    @Override
    public void beforeEnter(BeforeEnterEvent event) {
        
        setOpened(true);
    }
}

When I run it the onAttach() method is called twice, I read on attach called two times on output.

The view is instantiated from another view via a beforeEnter(BeforeEnterEvent event) using event.forwardTo(LoginView.class).

Why ? is this a bug?

Thanks for the help.

0 Answers
Related