@RequestMapping( value = "save", method = {RequestMethod.POST}) public String save( @Valid @ModelAttribute Guest newGuest, BindingResult result, Model model, HttpServletResponse response) { if (result.hasErrors()) { GuestWrapper guestWrapper = guestService.getLocaleInformationForForm(); model.addAttribute("countries", guestWrapper.getCountries()); model.addAttribute("states", guestWrapper.getStates()); model.addAttribute("cities", guestWrapper.getCities()); GuestbookController.UNITEDSTATESCOUNTRYID = guestWrapper.getUnitedStates().getPk(); GuestbookController.MASSACHUSETTSSTATEID = guestWrapper.getMassachusetts().getPk(); return "guestbook"; } guestService.addNewGuest(newGuest); emailService.sendThankyouEmail(newGuest.getEmail(), newGuest.getName()); return "thankyou"; }
@RequestMapping( value = "getCities", method = {RequestMethod.GET}, produces = "text/html") @ResponseBody public String getCities(@RequestParam("stateID") Integer stateID) { return guestService.updateCityOptions(stateID); }
@RequestMapping( value = "getStates", method = {RequestMethod.GET}, produces = "text/html") @ResponseBody public String getStates(@RequestParam("countryID") Integer countryID) { return guestService.updateStateOptions(countryID); }
@RequestMapping( value = "getGuestbookForm", method = {RequestMethod.GET}) public String getGuestbookForm(Model model) { GuestWrapper guestWrapper = guestService.getLocaleInformationForForm(); model.addAttribute("countries", guestWrapper.getCountries()); model.addAttribute("states", guestWrapper.getStates()); model.addAttribute("cities", guestWrapper.getCities()); model.addAttribute("unitedStatesCountryID", guestWrapper.getUnitedStates().getPk()); model.addAttribute("massachusettsStateID", guestWrapper.getMassachusetts().getPk()); GuestbookController.UNITEDSTATESCOUNTRYID = guestWrapper.getUnitedStates().getPk(); GuestbookController.MASSACHUSETTSSTATEID = guestWrapper.getMassachusetts().getPk(); return "guestbook"; }