@RequestMapping(value = "/update-profile", method = RequestMethod.POST) @RequireHardLogIn public String updateProfile( final UpdateProfileForm updateProfileForm, final BindingResult bindingResult, final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException { getProfileValidator().validate(updateProfileForm, bindingResult); String returnAction = ControllerConstants.Views.Pages.Account.AccountProfileEditPage; final CustomerData currentCustomerData = customerFacade.getCurrentCustomer(); final CustomerData customerData = new CustomerData(); customerData.setTitleCode(updateProfileForm.getTitleCode()); customerData.setFirstName(updateProfileForm.getFirstName()); customerData.setLastName(updateProfileForm.getLastName()); customerData.setUid(currentCustomerData.getUid()); customerData.setDisplayUid(currentCustomerData.getDisplayUid()); model.addAttribute("titleData", userFacade.getTitles()); if (bindingResult.hasErrors()) { GlobalMessages.addErrorMessage(model, "form.global.error"); } else { try { customerFacade.updateProfile(customerData); GlobalMessages.addFlashMessage( redirectAttributes, GlobalMessages.CONF_MESSAGES_HOLDER, "text.account.profile.confirmationUpdated", null); returnAction = REDIRECT_TO_PROFILE_PAGE; } catch (final DuplicateUidException e) { bindingResult.rejectValue("email", "registration.error.account.exists.title"); GlobalMessages.addErrorMessage(model, "form.global.error"); } } storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); return returnAction; }
@RequestMapping(value = "/update-profile", method = RequestMethod.GET) @RequireHardLogIn public String editProfile(final Model model) throws CMSItemNotFoundException { model.addAttribute("titleData", userFacade.getTitles()); final CustomerData customerData = customerFacade.getCurrentCustomer(); final UpdateProfileForm updateProfileForm = new UpdateProfileForm(); updateProfileForm.setTitleCode(customerData.getTitleCode()); updateProfileForm.setFirstName(customerData.getFirstName()); updateProfileForm.setLastName(customerData.getLastName()); model.addAttribute("updateProfileForm", updateProfileForm); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountProfileEditPage; }