Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

LoginForm does not work

Thomas Mauch
1 decade ago Mar 26, 2010 10:18pm
Joonas Lehtinen
1 decade ago Mar 27, 2010 10:36pm
Joonas Lehtinen
1 decade ago Mar 27, 2010 10:43pm

While the bug is being fixed, you can easily go around it by switching layouts instead of windows. Something like this works fine:

package com.example.logintest;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.LoginForm.LoginEvent;
import com.vaadin.ui.LoginForm.LoginListener;

@SuppressWarnings("serial")
public class LogintestApplication extends Application {

    LoginForm lf = new LoginForm();

    @Override
    public void init() {
        Window main = new Window("My App");
        setMainWindow(main);
        main.getContent().setSizeFull();
        main.addComponent(lf);
        lf.addListener(new LoginListener() {
            public void onLogin(LoginEvent event) {
                loggedIn();
            }
        });
    }

    private void loggedIn() {
        VerticalLayout appLayout = new VerticalLayout();
        getMainWindow().setContent(appLayout);
        appLayout.addComponent(new Label("My app goes here"));
        appLayout.addComponent(new Button("Logout", new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                close();
            }
        }));
    }
}
Thomas Mauch
1 decade ago Mar 30, 2010 11:09pm