Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveController.java =================================================================== diff -u -rf2ad75cef0c507a64877942631fee13efbc6ed50 -r43bf12a36195acd5fa20bb275ced93b8e0a0aecc --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveController.java (.../ProfileSaveController.java) (revision f2ad75cef0c507a64877942631fee13efbc6ed50) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveController.java (.../ProfileSaveController.java) (revision 43bf12a36195acd5fa20bb275ced93b8e0a0aecc) @@ -46,30 +46,32 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; /** * @author jliew */ @Controller public class ProfileSaveController { private static Logger log = Logger.getLogger(ProfileSaveController.class); - + @Autowired private IUserManagementService userManagementService; @Autowired @Qualifier("centralMessageService") private MessageService messageService; @RequestMapping(path = "/saveprofile") - public String execute(@ModelAttribute("newForm") UserForm userForm, HttpServletRequest request) throws Exception { + public String execute(@ModelAttribute("newForm") UserForm userForm, @RequestParam boolean editNameOnly, + HttpServletRequest request) throws Exception { MultiValueMap errorMap = new LinkedMultiValueMap<>(); if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE)) { if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { return "forward:/profile/edit.do"; } } - + request.setAttribute("submitted", true); User requestor = userManagementService.getUserByLogin(request.getRemoteUser()); @@ -101,17 +103,19 @@ } //user email validation - String userEmail = (userForm.getEmail() == null) ? null : (String) userForm.getEmail(); - if (StringUtils.isBlank(userEmail)) { - errorMap.add("email", messageService.getMessage("error.email.required")); - } else if (!ValidationUtil.isEmailValid(userEmail)) { - errorMap.add("email", messageService.getMessage("error.valid.email.required")); - } + if (!editNameOnly) { + String userEmail = (userForm.getEmail() == null) ? null : (String) userForm.getEmail(); + if (StringUtils.isBlank(userEmail)) { + errorMap.add("email", messageService.getMessage("error.email.required")); + } else if (!ValidationUtil.isEmailValid(userEmail)) { + errorMap.add("email", messageService.getMessage("error.valid.email.required")); + } - //country validation - String country = (userForm.getCountry() == null) ? null : (String) userForm.getCountry(); - if (StringUtils.isBlank(country) || "0".equals(country)) { - errorMap.add("email", messageService.getMessage("error.country.required")); + //country validation + String country = (userForm.getCountry() == null) ? null : (String) userForm.getCountry(); + if (StringUtils.isBlank(country) || "0".equals(country)) { + errorMap.add("email", messageService.getMessage("error.country.required")); + } } if (!errorMap.isEmpty()) { @@ -127,10 +131,14 @@ requestor.setEveningPhone(userForm.getEveningPhone()); requestor.setMobilePhone(userForm.getMobilePhone()); requestor.setFax(userForm.getFax()); + } else if (editNameOnly) { + requestor.setFirstName(userForm.getFirstName()); + requestor.setLastName(requestor.getLastName()); } else { // update all fields BeanUtils.copyProperties(requestor, userForm); - SupportedLocale locale = (SupportedLocale) userManagementService.findById(SupportedLocale.class, userForm.getLocaleId()); + SupportedLocale locale = (SupportedLocale) userManagementService.findById(SupportedLocale.class, + userForm.getLocaleId()); requestor.setLocale(locale); Theme cssTheme = (Theme) userManagementService.findById(Theme.class, userForm.getUserTheme()); Index: lams_central/web/profile/editprofile.jsp =================================================================== diff -u -r55b8032c2a73d3bc8e62fd2da4042dbdf1328c47 -r43bf12a36195acd5fa20bb275ced93b8e0a0aecc --- lams_central/web/profile/editprofile.jsp (.../editprofile.jsp) (revision 55b8032c2a73d3bc8e62fd2da4042dbdf1328c47) +++ lams_central/web/profile/editprofile.jsp (.../editprofile.jsp) (revision 43bf12a36195acd5fa20bb275ced93b8e0a0aecc) @@ -50,6 +50,7 @@ +