private void createLoginUI(final AbstractOrderedLayout parentLayout) { final Rpi_gpio_controllerApplication application = this; LoginForm loginForm = new LoginForm(); loginForm.addListener(new LoginForm.LoginListener() { Rpi_gpio_controllerApplication mApplication = application; public void onLogin(LoginEvent event) { String loginErrorMessage = new User(new UserData (event.getLoginParameter("username"), event.getLoginParameter("password")), mApplication).login(); if (loginErrorMessage != null) { Notification notification = new Notification(LoginErrorMessage, loginErrorMessage, Notification.TYPE_ERROR_MESSAGE); notification.setDelayMsec(1000); getMainWindow().showNotification(notification); } } }); Panel loginPanel = new Panel("Log in"); loginPanel.setWidth("200px"); loginPanel.setHeight("250px"); loginPanel.addComponent(loginForm); parentLayout.addComponent(loginPanel); parentLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
public void onLogin(LoginEvent event) { String userName = event.getLoginParameter("username"); // see the input field names in CustomLoginForm String password = event.getLoginParameter("password"); // see the input field names in CustomLoginForm // Delegate authentication to handler LoggedInUser loggedInUser = loginHandler.authenticate(userName, password); if (loggedInUser != null) { ExplorerApp.get().setUser(loggedInUser); viewManager.showDefaultPage(); } else { refreshUi(); notificationManager.showErrorNotification(Messages.LOGIN_FAILED_HEADER, i18nManager.getMessage(Messages.LOGIN_FAILED_INVALID)); } }