app/controllers/UserController.java
/**
     * Handle the 'new user form' submission
     */
Handle the 'new user form' submission
Handle the ' new user form ' submission
public Result saveUser() {
        List<ValidationError> errors = new ArrayList<>();
        Form<User> registerForm = formFactory.form(User.class).bindFromRequest();
        User user = null;
        String username = registerForm.get().username;
        user = User.IsUnique(username);
        if(user != null){
            System.out.println("Username not unique error");
            errors.add(new ValidationError("username", "username must be unique."));
            registerForm.errors().put("",errors);
        }
        if(registerForm.hasErrors()) {
            System.out.println("User Already Exists.");
            return badRequest(views.html.registerForm.render(registerForm, "" +username +" taken. Try different username."));
        }else {
            registerForm.get().save();
            Form<User> loginForm = formFactory.form(User.class);
            return ok(views.html.loginForm.render(loginForm, "User Created. Log In To Proceed:"));
        }
    }
public Result saveUser ( ) { List < ValidationError > errors = new ArrayList < > ( ) ; Form < User > registerForm = formFactory . form ( User . class ) . bindFromRequest ( ) ; User user = null ; String username = registerForm . get ( ) . username ; user = User . IsUnique ( username ) ; if ( user != null ) { System . out . println ( "Username not unique error" ) ; errors . add ( new ValidationError ( "username" , "username must be unique." ) ) ; registerForm . errors ( ) . put ( "" , errors ) ; } if ( registerForm . hasErrors ( ) ) { System . out . println ( "User Already Exists." ) ; return badRequest ( views . html . registerForm . render ( registerForm , "" + username + " taken. Try different username." ) ) ; } else { registerForm . get ( ) . save ( ) ; Form < User > loginForm = formFactory . form ( User . class ) ; return ok ( views . html . loginForm . render ( loginForm , "User Created. Log In To Proceed:" ) ) ; } }
Handle the 'new user form' submission
Handle the ' new user form ' submission