Example usage for org.springframework.validation BindingResult reject

List of usage examples for org.springframework.validation BindingResult reject

Introduction

In this page you can find the example usage for org.springframework.validation BindingResult reject.

Prototype

void reject(String errorCode);

Source Link

Document

Register a global error for the entire target object, using the given error description.

Usage

From source file:org.openmrs.module.cohort.web.controller.AddEncounter.java

@RequestMapping(value = "/module/cohort/addenc.form", method = RequestMethod.POST)
public ModelAndView onSubmit(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "encounterDateTime") String date,
        @RequestParam(required = false, value = "visit") Integer id,
        @ModelAttribute("cohortencounters") CohortEncounter cencounters, BindingResult errors) {
    CohortService departmentService = Context.getService(CohortService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("Required");
    }//  w w w  .  j ava  2s  .c  o m

    EncounterService enctype = Context.getEncounterService();
    List<EncounterType> enctypes = enctype.getAllEncounterTypes();
    EncounterType e = new EncounterType();
    Location l = new Location();
    LocationService service = Context.getLocationService();
    List<String> cohortnames = new ArrayList<String>();
    CohortService cservice = Context.getService(CohortService.class);
    CohortM c1 = new CohortM();
    Form f = new Form();
    CohortVisit cvis = new CohortVisit();
    FormService fs = Context.getFormService();
    List<String> fo = new ArrayList<String>();
    List<Form> form = fs.getAllForms();
    for (int h = 0; h < form.size(); h++) {
        Form b = form.get(h);
        fo.add(b.getName());
    }
    List<Integer> cvisit = new ArrayList<Integer>();
    List<CohortVisit> cv = cservice.findCohortVisit();
    for (int a = 0; a < cv.size(); a++) {
        CohortVisit v = cv.get(a);
        cvisit.add(v.getId());
    }
    model.addAttribute("forms", fo);
    model.addAttribute("visits", cvisit);
    List<CohortM> list1 = cservice.findCohorts();
    for (int d = 0; d < list1.size(); d++) {
        CohortM c = list1.get(d);
        cohortnames.add(c.getName());
    }
    List<String> etype = new ArrayList<String>();
    for (int k = 0; k < enctypes.size(); k++) {
        EncounterType ec = enctypes.get(k);
        etype.add(e.getName());
    }
    List<Location> formats = service.getAllLocations();
    model.addAttribute("locations", formats);
    model.addAttribute("enctypes", etype);

    String encountertype = request.getParameter("enctype");
    String location = request.getParameter("location");
    String cohort = request.getParameter("names");
    String f1 = request.getParameter("form");
    if (date == "") {
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Values cannot be null");
    } else {
        List<CohortM> cohort2 = cservice.findCohorts(cohort);
        for (int i = 0; i < cohort2.size(); i++) {
            c1 = cohort2.get(i);
        }
        List<EncounterType> enctypes1 = enctype.findEncounterTypes(encountertype);
        for (int g = 0; g < enctypes1.size(); g++) {
            e = enctypes1.get(g);
        }
        List<Location> loc = service.getLocations(location);
        for (int j = 0; j < loc.size(); j++) {
            l = loc.get(j);
        }
        List<Form> fm = fs.findForms(f1, false, false);
        for (int b = 0; b < fm.size(); b++) {
            f = fm.get(b);
        }
        List<CohortVisit> cvi = cservice.findCohortVisit(id);
        for (int c = 0; c < cvi.size(); c++) {
            cvis = cvi.get(c);
        }
        cencounters.setForm(f);
        cencounters.setVisit(cvis);
        cencounters.setCohort(c1);
        cencounters.setEncounterType(e);
        cencounters.setLocation(l);
        departmentService.saveCohortEncounters(cencounters);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "insertion success");
    }
    return null;
}

From source file:org.openmrs.module.cohort.web.controller.AddRoleController.java

@RequestMapping(value = "module/cohort/arole.form", method = RequestMethod.POST)
public String onSubmit(WebRequest request, HttpSession httpSession, HttpServletRequest request1,
        @RequestParam(required = false, value = "name") String cohort_name,
        @ModelAttribute("cohortrole") CohortRole cohortrole, BindingResult errors, ModelMap model) {
    CohortRole cr = new CohortRole();
    CohortType cohort1 = new CohortType();
    String cohort_type_name = request.getParameter("format");
    CohortService departmentService = Context.getService(CohortService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("Required");
    }/*  w  w w.j a va2  s .  co  m*/
    this.validator.validate(cohortrole, errors);
    System.out.println("Before BR");
    if (errors.hasErrors()) {
        System.out.println("BR has errors: " + errors.getErrorCount());
        System.out.println(errors.getAllErrors());
        return "/module/cohort/arole";
    }
    if (cohort_name.length() > 20) {
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "name cannot be greater than 20");
    } else {
        List<CohortType> cohorttype1 = departmentService.findCohortType(cohort_type_name);
        for (int i = 0; i < cohorttype1.size(); i++) {
            cohort1 = cohorttype1.get(i);
        }
        cohortrole.setCohortType(cohort1);
        departmentService.saveCohortRole(cohortrole);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "insertion success");
        model.addAttribute("formats", cohorttype1);
    }
    //}
    /*catch (ParseException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }     
    }*/
    return null;
}

From source file:org.openmrs.module.patientmodule.web.controller.PatientModuleManageController.java

@RequestMapping(value = "/module/patientmodule/addPatientModule.form", method = RequestMethod.POST)
public String submitPatientModule(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "action") String action,
        @ModelAttribute("patientModule") PatientModule patientModule, BindingResult errors) {

    MessageSourceService mss = Context.getMessageSourceService();
    model.addAttribute("hello", "");
    PatientModuleService patientModuleService = Context.getService(PatientModuleService.class);
    if (!Context.isAuthenticated()) {
        errors.reject("patientModule.auth.required");
    } else if (mss.getMessage("patientModule.purgePatientModule").equals(action)) {
        try {//from  w  w  w  .  j  av a  2 s.co m
            patientModuleService.purgePatientModule(patientModule);
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "patientModule.delete.success");
            return "redirect:patientModuleList.list";
        } catch (Exception ex) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "patientModule.delete.failure");
            log.error("Failed to delete patientModule", ex);
            return "redirect:patientModuleForm.form?nationalId=" + request.getParameter("nationalId");
        }
    } else {
        patientModuleService.savePatient(patientModule);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "patientModule.saved");
    }
    return "redirect:patientModuleList.list";
}

From source file:org.openmrs.module.registrationapp.RegistrationAppUiUtils.java

public static void validateLatitudeAndLongitudeIfNecessary(PersonAddress address, BindingResult errors) {
    if (address != null) {

        Map<String, String> regex = Context
                .getRegisteredComponent(AddressSupportCompatibility.ID, AddressSupportCompatibility.class)
                .getElementRegex();//w  w  w . j  a va  2s  .co m

        if (StringUtils.isNotBlank(address.getLatitude())) {
            if (regex != null && StringUtils.isBlank(regex.get("latitude"))) {
                if (!RegistrationAppUiUtils.isValidLatitude(address.getLatitude())) {
                    errors.reject("registrationapp.latitude.invalid");
                }
            }
        }

        if (StringUtils.isNotBlank(address.getLongitude())) {
            if (regex != null && StringUtils.isBlank(regex.get("longitude"))) {
                if (!RegistrationAppUiUtils.isValidLongitude(address.getLongitude())) {
                    errors.reject("registrationapp.longitude.invalid");
                }
            }
        }
    }
}

From source file:org.openmrs.web.controller.user.UserFormController.java

/**
 * @should work for an example/*  w w w .  j  a v a 2  s.  c  om*/
 */
@RequestMapping(value = "/admin/users/user.form", method = RequestMethod.POST)
public String handleSubmission(WebRequest request, HttpSession httpSession, ModelMap model,
        @RequestParam(required = false, value = "action") String action,
        @RequestParam(required = false, value = "userFormOldPassword") String oldPassword,
        @RequestParam(required = false, value = "userFormPassword") String password,
        @RequestParam(required = false, value = "secretQuestion") String secretQuestion,
        @RequestParam(required = false, value = "secretAnswer") String secretAnswer,
        @RequestParam(required = false, value = "confirm") String confirm,
        @RequestParam(required = false, value = "forcePassword") Boolean forcePassword,
        @RequestParam(required = false, value = "roleStrings") String[] roles,
        @RequestParam(required = false, value = "createNewPerson") String createNewPerson,
        @ModelAttribute("user") User user, BindingResult errors) {

    UserService us = Context.getUserService();
    MessageSourceService mss = Context.getMessageSourceService();

    if (!Context.isAuthenticated()) {
        errors.reject("auth.invalid");
    } else if (mss.getMessage("User.assumeIdentity").equals(action)) {
        Context.becomeUser(user.getSystemId());
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "User.assumeIdentity.success");
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ARGS, user.getPersonName());
        return "redirect:/index.htm";

    } else if (mss.getMessage("User.delete").equals(action)) {
        try {
            Context.getUserService().purgeUser(user);
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "User.delete.success");
            return "redirect:users.list";
        } catch (Exception ex) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "User.delete.failure");
            log.error("Failed to delete user", ex);
            return "redirect:/admin/users/user.form?userId=" + request.getParameter("userId");
        }

    } else if (mss.getMessage("User.retire").equals(action)) {
        String retireReason = request.getParameter("retireReason");
        if (!(StringUtils.hasText(retireReason))) {
            errors.rejectValue("retireReason", "User.disableReason.empty");
            return showForm(user.getUserId(), createNewPerson, user, model);
        } else {
            us.retireUser(user, retireReason);
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "User.retiredMessage");
        }

    } else if (mss.getMessage("User.unRetire").equals(action)) {
        us.unretireUser(user);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "User.unRetiredMessage");
    } else {

        // check if username is already in the database
        if (us.hasDuplicateUsername(user)) {
            errors.rejectValue("username", "error.username.taken");
        }

        // check if password and password confirm are identical
        if (password == null || password.equals("XXXXXXXXXXXXXXX")) {
            password = "";
        }
        if (confirm == null || confirm.equals("XXXXXXXXXXXXXXX")) {
            confirm = "";
        }

        if (!password.equals(confirm)) {
            errors.reject("error.password.match");
        }

        if (password.length() == 0 && isNewUser(user)) {
            errors.reject("options.login.password.null");
        }

        //check password strength
        if (password.length() > 0) {
            try {
                OpenmrsUtil.validatePassword(user.getUsername(), password, user.getSystemId());
            } catch (PasswordException e) {
                errors.reject(e.getMessage());
            }
        }

        Set<Role> newRoles = new HashSet<Role>();
        if (roles != null) {
            for (String r : roles) {
                // Make sure that if we already have a detached instance of this role in the
                // user's roles, that we don't fetch a second copy of that same role from
                // the database, or else hibernate will throw a NonUniqueObjectException.
                Role role = null;
                if (user.getRoles() != null) {
                    for (Role test : user.getRoles()) {
                        if (test.getRole().equals(r)) {
                            role = test;
                        }
                    }
                }
                if (role == null) {
                    role = us.getRole(r);
                    user.addRole(role);
                }
                newRoles.add(role);
            }
        }

        if (user.getRoles() == null) {
            newRoles.clear();
        } else {
            user.getRoles().retainAll(newRoles);
        }

        String[] keys = request.getParameterValues("property");
        String[] values = request.getParameterValues("value");

        if (keys != null && values != null) {
            for (int x = 0; x < keys.length; x++) {
                String key = keys[x];
                String val = values[x];
                user.setUserProperty(key, val);
            }
        }

        if (StringUtils.hasLength(secretQuestion) && !StringUtils.hasLength(secretAnswer)) {
            errors.reject("error.User.secretAnswer.empty");
        } else if (!StringUtils.hasLength(secretQuestion) && StringUtils.hasLength(secretAnswer)) {
            errors.reject("error.User.secretQuestion.empty");
        }

        new UserProperties(user.getUserProperties()).setSupposedToChangePassword(forcePassword);

        userValidator.validate(user, errors);

        if (errors.hasErrors()) {
            return showForm(user.getUserId(), createNewPerson, user, model);
        }

        if (isNewUser(user)) {
            us.createUser(user, password);
        } else {
            us.saveUser(user);

            if (!"".equals(password) && Context.hasPrivilege(PrivilegeConstants.EDIT_USER_PASSWORDS)) {
                if (log.isDebugEnabled()) {
                    log.debug("calling changePassword for user " + user + " by user "
                            + Context.getAuthenticatedUser());
                }
                us.changePassword(user, oldPassword, password);
            }
        }

        if (StringUtils.hasLength(secretQuestion) && StringUtils.hasLength(secretAnswer)) {
            us.changeQuestionAnswer(user, secretQuestion, secretAnswer);
        }

        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "User.saved");
    }
    return "redirect:users.list";
}

From source file:org.opennms.web.controller.EditForeignSourceController.java

/**
 * @return View for this controller action
 *///from w w  w  .j  a va2s  .  com
@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(@ModelAttribute(COMMAND_NAME) @Valid TreeCommand treeCmd, BindingResult errors) {

    LOG.debug("treeCmd = {}", treeCmd);

    if (errors.hasErrors()) {
        return new ModelAndView("/admin/editForeignSource", COMMAND_NAME, treeCmd);
    }

    String action = treeCmd.getAction();
    if (action == null) {
        // Do nothing
    } else if ("addDetector".equalsIgnoreCase(action)) {
        doAddDetector(treeCmd);
    } else if ("addPolicy".equalsIgnoreCase(action)) {
        doAddPolicy(treeCmd);
    } else if ("addParameter".equalsIgnoreCase(action)) {
        doAddParameter(treeCmd);
    } else if ("save".equalsIgnoreCase(action)) {
        doSave(treeCmd);
    } else if ("edit".equalsIgnoreCase(action)) {
        doEdit(treeCmd);
    } else if ("cancel".equalsIgnoreCase(action)) {
        doCancel(treeCmd);
    } else if ("delete".equalsIgnoreCase(action)) {
        doDelete(treeCmd);
    } else if ("done".equalsIgnoreCase(action)) {
        return done(treeCmd);
    } else {
        errors.reject("Unrecognized action: " + action);
    }

    return new ModelAndView("/admin/editForeignSource", COMMAND_NAME, treeCmd);
}

From source file:org.opennms.web.controller.EditProvisioningGroupController.java

/**
 * @return View for this controller action
 *//*from  w  ww.  j  a v a2 s  . co m*/
@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(@ModelAttribute(COMMAND_NAME) @Valid TreeCommand treeCmd, BindingResult errors,
        HttpSession session) {

    if (errors.hasErrors()) {
        return new ModelAndView("/admin/editProvisioningGroup", COMMAND_NAME, treeCmd);
    }

    String action = treeCmd.getAction();
    if (action == null) {
        // Do nothing
    } else if ("toggleFreeForm".equalsIgnoreCase(action)) {
        Boolean isFreeForm = (Boolean) session.getAttribute("freeFormEditing");
        if (isFreeForm == null) {
            isFreeForm = false;
        }
        session.setAttribute("freeFormEditing", !isFreeForm);
    } else if ("addNode".equalsIgnoreCase(action)) {
        doAddNode(treeCmd);
    } else if ("addInterface".equalsIgnoreCase(action)) {
        doAddInterface(treeCmd);
    } else if ("addService".equalsIgnoreCase(action)) {
        doAddService(treeCmd);
    } else if ("addCategory".equalsIgnoreCase(action)) {
        doAddCategory(treeCmd);
    } else if ("addAssetField".equalsIgnoreCase(action)) {
        doAddAssetField(treeCmd);
    } else if ("save".equalsIgnoreCase(action)) {
        doSave(treeCmd, errors);
    } else if ("edit".equalsIgnoreCase(action)) {
        doEdit(treeCmd);
    } else if ("cancel".equalsIgnoreCase(action)) {
        doCancel(treeCmd);
    } else if ("delete".equalsIgnoreCase(action)) {
        doDelete(treeCmd);
    } else if ("import".equalsIgnoreCase(action)) {
        doImport(treeCmd);
    } else if ("done".equalsIgnoreCase(action)) {
        return done(treeCmd);
    } else {
        errors.reject("Unrecognized action: " + action);
    }

    return new ModelAndView("/admin/editProvisioningGroup", COMMAND_NAME, treeCmd);
}

From source file:org.opennms.web.controller.EditProvisioningGroupController.java

private void doSave(TreeCommand treeCmd, BindingResult errors) {
    try {//from   w ww .j a  v  a2 s.c o  m
        LOG.debug("treeCmd = {}", treeCmd);
        treeCmd.getFormData().validate();
        final Requisition formData = m_provisioningService.saveProvisioningGroup(treeCmd.getGroupName(),
                treeCmd.getFormData());
        treeCmd.setFormData(formData);
        treeCmd.setCurrentNode("");
    } catch (final Throwable t) {
        errors.reject(t.getMessage());
    }
}

From source file:org.wise.portal.presentation.web.controllers.forgotaccount.ResetPasswordController.java

/**
 * Performs processing whenever the resetpassword.html form is shown.
 * This handles displaying the form when the user is requested to
 * enter a new password and also handles displaying the form when
 * the user successfully changes their password.
 * @param passwordReminderParameters the object that contains values from the form
 * @param bindingResult the object used for validation in which errors will be stored
 * @param modelMap the model object that contains values for the page to use when rendering the view
 * @param request the http request/*w  ww .  jav  a2 s  .c om*/
 * @return the path of the view to display
 */
@RequestMapping(method = RequestMethod.GET)
public String initializeForm(
        @ModelAttribute("passwordReminderParameters") PasswordReminderParameters passwordReminderParameters,
        BindingResult bindingResult, ModelMap modelMap, HttpServletRequest request) throws Exception {
    //get the reset password key
    String resetPasswordKey = request.getParameter("k");

    //boolean values that will be used in the jsp to determine what to display
    boolean displayForgotPasswordSelectAccountTypeLink = false;
    boolean displayLoginLink = false;
    boolean passwordResetSuccess = false;

    /*
     * determine if we have successfully reset the password.
     * this will only be true after they have submitted the
     * password change form successfully and we call showForm()
     * again.
     */
    if (request.getAttribute("passwordResetSuccess") != null) {
        passwordResetSuccess = (Boolean) request.getAttribute("passwordResetSuccess");
    }

    if (passwordResetSuccess) {
        //we want to display the success page and display a link to login
        displayLoginLink = true;
    } else {
        //make sure we have a reset password key
        if (resetPasswordKey != null) {
            //get the user associated with this reset password key
            User user = userService.retrieveByResetPasswordKey(resetPasswordKey);

            if (user != null) {
                //get the time the reset password email was sent
                MutableUserDetails userDetails = user.getUserDetails();
                Date resetPasswordRequestTime = userDetails.getResetPasswordRequestTime();
                long resetPasswordRequestTimeMs = resetPasswordRequestTime.getTime();

                //get the current time
                Date now = new Date();
                long nowMs = now.getTime();

                /*
                 * check if the reset password request has expired because it was made 
                 * more than 30 minutes ago
                 * 1000 * 60 * 30 = 1800000
                 */
                if (nowMs - resetPasswordRequestTimeMs > 1800000) {
                    //reset password link has expired 
                    bindingResult.reject("error.password-reset-timeout");

                    //variable to tell the jsp page to display the link to the forgot password page
                    displayForgotPasswordSelectAccountTypeLink = true;
                }
            } else {
                /*
                 * we could not find a user with the given reset password 
                 * key so this password reset url is invalid
                 */
                bindingResult.reject("error.invalid-password-reset-url");

                //variable to tell the jsp page to display the link to the forgot password page
                displayForgotPasswordSelectAccountTypeLink = true;
            }
        } else {
            //there is no reset password key provided as a GET param so this password reset url is invalid
            bindingResult.reject("error.invalid-password-reset-url");

            //variable to tell the jsp page to display the link to the forgot password page
            displayForgotPasswordSelectAccountTypeLink = true;
        }
    }

    modelMap.addAttribute("displayForgotPasswordSelectAccountTypeLink",
            displayForgotPasswordSelectAccountTypeLink);
    modelMap.addAttribute("displayLoginLink", displayLoginLink);

    return formView;
}

From source file:org.wise.portal.presentation.web.controllers.forgotaccount.ResetPasswordController.java

/**
 * Called when the user chooses a new password and submits the form.
 * @param passwordReminderParameters the object that contains values from the form
 * @param bindingResult the object used for validation in which errors will be stored
 * @param modelMap the model object that contains values for the page to use when rendering the view
 * @param request the http request//  w  w  w  .  j av a  2 s  . co m
 * @return the path of the view to display
 */
@RequestMapping(method = RequestMethod.POST)
protected String onSubmit(
        @ModelAttribute("passwordReminderParameters") PasswordReminderParameters passwordReminderParameters,
        BindingResult bindingResult, Model model, HttpServletRequest request) throws Exception {
    String view = formView;

    //get the password values the user entered
    String newPassword = passwordReminderParameters.getNewPassword();
    String verifyPassword = passwordReminderParameters.getVerifyPassword();

    //make the passwords lower case
    verifyPassword = StringUtils.lowerCase(verifyPassword);
    newPassword = StringUtils.lowerCase(newPassword);

    if (!verifyPassword.equals(newPassword)) {
        //passwords are not the same
        bindingResult.reject("error.verify-newpassword");

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //do not display the sign in button
        model.addAttribute("displayLoginLink", false);
    } else if (verifyPassword.equals("")) {
        //password is empty string
        bindingResult.reject("error.verify-password-empty");

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //do not display the sign in button
        model.addAttribute("displayLoginLink", false);
    } else {
        //get the reset password key
        String resetPasswordKey = request.getParameter("k");

        //get the user associated with the reset password key
        User user = userService.retrieveByResetPasswordKey(resetPasswordKey);

        //update the user's password
        userService.updateUserPassword(user, verifyPassword);

        //set the reset password key and time so the key can no longer be used
        user.getUserDetails().setResetPasswordKey(null);
        user.getUserDetails().setResetPasswordRequestTime(null);
        userService.updateUser(user);

        //get the user name
        String username = user.getUserDetails().getUsername();

        //get the portal name
        String portalName = wiseProperties.getProperty("wise.name");

        //get the user's email
        String userEmail = user.getUserDetails().getEmailAddress();
        String[] recipients = new String[] { userEmail };

        // get user Locale
        Locale userLocale = request.getLocale();

        // subject looks like this: "Notification from WISE4@Berkeley: Password Changed"
        String defaultSubject = messageSource.getMessage(
                "forgotaccount.teacher.index.passwordChangedEmailSubject", new Object[] { portalName },
                Locale.US);
        String subject = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailSubject",
                new Object[] { portalName }, defaultSubject, userLocale);
        String defaultBody = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailBody",
                new Object[] { username, portalName }, Locale.US);
        String body = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailBody",
                new Object[] { username, portalName }, defaultBody, userLocale);

        // send password in the email here
        mailService.postMail(recipients, subject, body, userEmail);

        //passwords are the same so we will change their password
        bindingResult.reject("changePassword_success");

        //tell the jsp to display the success message
        request.setAttribute("passwordResetSuccess", true);

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //display the sign in button
        model.addAttribute("displayLoginLink", true);
    }

    return view;
}