LoginForm seems to be broken

I’m just trying to get the LoginForm working. But I got some issues:

  1. The iframe displays “false” and reloads, then the login form appears
  2. It looks crappy (Has background color and the Button is broken)
  3. It doesn’t update the view (I have to do a manual refresh)

This is my test code:

public class TestApp extends Application implements LoginListener {

  @Override
  public void init() {
    if ( getUser() == null ) {
      showLoginForm();
      return;
    }
    Window window = new Window();
    window.addComponent( new Label( "Logged in as " + getUser() ) );
    setMainWindow( window );
  }

  @Override
  public void onLogin( LoginEvent event ) {
    setUser( event.getLoginParameter( "username" ) );
    init();
  }

  private void showLoginForm() {
    setMainWindow( new Window() );

    Window w = new Window( "Login" );
    getMainWindow().addWindow( w );

    LoginForm loginForm = new LoginForm();
    loginForm.addListener( this );
    w.addComponent( loginForm );
    w.center();
  }
}

Is it completely buggy, or am I doing something wrong?

You are absolutely correct. Wrote a ticket:
http://dev.vaadin.com/ticket/3597

You created the ticket for the broken button… but what’s with the “false” issue and the not working, let me say, “repainting”?

Thanks. Added this to the ticket.

Just to add. It seems that this is a regression 6.1.3. Previous version - 6.1.2 should work.

Hi!

I fixed the ticket filled by Joonas. Today I saw spotted your forum post. I’d still want to give you two hints with Vaadin coding.

First of all, avoid calling init method multiple times. It is meant to build the main screen show to the user when the application is instantiated. It just makes things more complicated to use it to do other things too. Extra methods don’t cost you anything.

The second thing I’d suggest to change is resetting the main window. You should have window.open() there too to get you “new main window” visible. That needs a complete reload on client side, (and ultimately causing flickering especially in FF). You might also face some problems with uri handlers and parameter handlers. The same thing goes for all top level window changes: avoid them if you can. Most commonly this is achieved by making you views extending layouts instead of windows.

With these hints, your test app could become something like this:


    private Window loginSubWindow;

    @Override
    public void init() {
        showLoginForm();
    }

    public void onLogin(LoginEvent event) {
        setUser(event.getLoginParameter("username"));
        getMainWindow().removeWindow(loginSubWindow);
        getMainWindow().addComponent(new Label("Logged in as " + getUser()));
    }

    private void showLoginForm() {
        setMainWindow(new Window());

        loginSubWindow = new Window("Login");
        getMainWindow().addWindow(loginSubWindow);
        loginSubWindow.getContent().setHeight("150px");
        loginSubWindow.getContent().setWidth("400px");

        LoginForm loginForm = new LoginForm();
        loginForm.addListener(this);
        loginSubWindow.addComponent(loginForm);
        loginSubWindow.center();

Thanks for that.

With 6.1.4. it looks better, even the “false” is still displayed for a very short time (usually not visible) but this doesn’t bother me. However, there are still two things broken: