Example usage for com.vaadin.ui LoginForm LoginForm

List of usage examples for com.vaadin.ui LoginForm LoginForm

Introduction

In this page you can find the example usage for com.vaadin.ui LoginForm LoginForm.

Prototype

LoginForm

Source Link

Usage

From source file:org.vaadin.training.fundamentals.happening.ui.viewimpl.LoginViewImpl.java

License:Creative Commons License

@SuppressWarnings("serial")
private void showLoginWindow() {
    if (loginWindow != null && loginWindow.getParent() != null) {
        return;//  w  w w.j a  va 2  s .  com
    }
    loginLayout = new CssLayout();
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login");
    loginWindow = new Window(tr.getString("LoginWindow.Caption"), loginLayout);
    loginWindow.setWidth("60%");
    loginWindow.setHeight("60%");
    loginWindow.setClosable(false);
    loginWindow.setModal(true);
    loginWindow.center();

    LoginForm loginForm = new LoginForm();
    loginForm.setSizeUndefined();
    loginForm.addListener(new LoginListener() {
        @Override
        public void onLogin(LoginEvent event) {
            String accountId = event.getLoginParameter("username");
            String password = event.getLoginParameter("password");
            LoginViewImpl.this.getWindow().removeWindow(event.getComponent().getWindow());
            LoginViewImpl.this.fireEvent(new LoginAttemptEvent(LoginViewImpl.this, accountId, password));
        }
    });

    loginLayout.addComponent(loginForm);

    // Label photoAttribution = new Label(
    // "Photo by Curtis Fry. Licensed under Creative Commons");
    // photoAttribution.setSizeUndefined();
    // photoAttribution.addStyleName("photoAttribution");
    // loginLayout.addComponent(photoAttribution);

    // TextField username = new
    // TextField(tr.getString("LoginView.Username"));
    // loginLayout.addComponent(username, "username");
    // PasswordField password = new PasswordField(
    // tr.getString("LoginView.Password"));
    // loginLayout.addComponent(password, "password");
    //
    // Button registerButton = new Button(tr.getString("Button.Register"));
    // registerButton.addListener(new Button.ClickListener() {
    // @Override
    // public void buttonClick(ClickEvent event) {
    // }
    // });
    // loginLayout.addComponent(registerButton, "registerButton");

    getWindow().addWindow(loginWindow);
}

From source file:sweforce.vaadin.security.activitiesandplaces.login.LoginViewImpl.java

License:Apache License

public LoginViewImpl() {
    mainLayout.setSizeFull();/* w ww  .  j a va 2  s.  com*/
    loginPanel = new Panel("Login");
    mainLayout.addComponent(loginPanel);
    mainLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    loginPanel.setSizeUndefined();

    LoginForm loginForm;
    loginForm = new LoginForm();
    loginPanel.setContent(loginForm);
    loginForm.setPasswordCaption("Password"); //i18n?
    loginForm.setUsernameCaption("User");
    loginForm.setLoginButtonCaption("Login");
    //        loginForm.setHeight("100px");
    loginForm.addListener(this);
}

From source file:VaadinIRC.main.java

License:Open Source License

/**
 * Shows login panel for the user.//ww w .j  av a 2  s  .  c om
 */
private void showLoginPanel() {
    loginPanel = new Panel("Login");
    loginPanel.setWidth(250, Sizeable.UNITS_PIXELS);
    loginPanel.setHeight(200, Sizeable.UNITS_PIXELS);
    LoginForm login = new LoginForm();
    loginPanel.addComponent(login);
    window.addComponent(loginPanel);
    VerticalLayout windowLayout = (VerticalLayout) window.getLayout();
    windowLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);

    login.addListener(new LoginListener() {
        public void onLogin(LoginEvent event) {
            String username = event.getLoginParameter("username");
            String password = event.getLoginParameter("password");
            if (username.equals(settings.AUTHENTICATION_USERNAME)
                    && password.equals(settings.AUTHENTICATION_PASSWORD)) {
                window.removeComponent(loginPanel);
                startMainApplication();
            } else {
                Notification notification = new Notification("Wrong username or password.",
                        Notification.TYPE_ERROR_MESSAGE);
                notification.setPosition(Notification.POSITION_BOTTOM_RIGHT);
                notification.setDelayMsec(250);
                window.showNotification(notification);
            }
        }
    });
}