Generate Login View

  1. In the Project Management > User Interface click on image not found Create new GUI element.

  2. In the following dialog, specify a name for the view at Name.

  3. Select Template > Login View with Login Form.

  4. Click Finish.
    image not found

  5. Click OK in the following note about the RapidClipse framework.

  6. In the following dialog, select your Authenticator Provider.

  7. Click on Finish.
    image not found

Result:

  • GUI Builder - A default login view is generated in the GUI Builder.
    image not found

  • Javacode - All javacode for this will be generated automatically.

    package com.company.demoproject.ui;
    
    import com.company.demoproject.MyAuthenticationProvider;
    import com.rapidclipse.framework.security.authentication.CredentialsUsernamePassword;
    import com.rapidclipse.framework.server.security.authentication.Authentication;
    import com.vaadin.flow.component.ComponentEvent;
    import com.vaadin.flow.component.ComponentEventListener;
    import com.vaadin.flow.component.login.AbstractLogin.ForgotPasswordEvent;
    import com.vaadin.flow.component.login.AbstractLogin.LoginEvent;
    import com.vaadin.flow.component.login.LoginForm;
    import com.vaadin.flow.component.orderedlayout.FlexComponent;
    import com.vaadin.flow.component.orderedlayout.VerticalLayout;
    
    
    @com.rapidclipse.framework.server.security.authentication.LoginView
    public class LoginView extends VerticalLayout
    {
        public LoginView()
        {
            super();
            initUI();
        }
    
        /**
         * Event handler delegate method for the {@link LoginForm} {@link #loginForm}.
         *
         * @see ComponentEventListener#onComponentEvent(ComponentEvent)
         * @eventHandlerDelegate Do NOT delete, used by UI designer!
         */
        private void loginForm_onLogin(final LoginEvent event)
        {
            final CredentialsUsernamePassword credentials = CredentialsUsernamePassword.New(
                event.getUsername(), event.getPassword());
    
            MyAuthenticationProvider authenticatorProvider = MyAuthenticationProvider.getInstance();
    
            if(!Authentication.tryLogin(credentials, authenticatorProvider))
            {
                this.loginForm.setError(true);
            }
        }
    
        /**
         * Event handler delegate method for the {@link LoginForm} {@link #loginForm}.
         *
         * @see ComponentEventListener#onComponentEvent(ComponentEvent)
         * @eventHandlerDelegate Do NOT delete, used by UI designer!
         */
        private void loginForm_onForgotPassword(final ForgotPasswordEvent event)
        {
            // TODO provide password recovery
        }
    
        /* WARNING: Do NOT edit!<br>The content of this method is always regenerated by the UI designer. */
        // <generated-code name="initUI">
        private void initUI()
        {
            this.loginForm = new LoginForm();
    
            this.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
            this.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
    
            this.add(this.loginForm);
            this.setSizeFull();
    
            this.loginForm.addLoginListener(this::loginForm_onLogin);
            this.loginForm.addForgotPasswordListener(this::loginForm_onForgotPassword);
        } // </generated-code>
    
        // <generated-code name="variables">
        private LoginForm loginForm;
        // </generated-code>
    
    }