@RequestMapping(method = RequestMethod.POST) public ModelAndView processFormSubmit( @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @Valid @ModelAttribute("formBean") HolidayFormBean formBean, BindingResult result, SessionStatus status) { ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN); if (StringUtils.isNotBlank(cancel)) { status.setComplete(); } else if (result.hasErrors()) { mav = new ModelAndView("defineNewHoliday"); } else { HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean); List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds()); OfficeHoliday officeHoliday = holidayServiceFacade.retrieveHolidayDetailsForPreview(holidayDetail, branchIds); List<String> otherHolidays = holidayServiceFacade.retrieveOtherHolidayNamesWithTheSameDate(holidayDetail, branchIds); mav = new ModelAndView("previewHoliday"); mav.addObject("formBean", formBean); mav.addObject("officeHoliday", officeHoliday); mav.addObject("otherHolidays", otherHolidays); } return mav; }
@RequestMapping(method = RequestMethod.POST) public ModelAndView processFormSubmit( @RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") HolidayFormBean formBean, BindingResult result, SessionStatus status) { String viewName = REDIRECT_TO_ADMIN_SCREEN; ModelAndView modelAndView = new ModelAndView(); if (StringUtils.isNotBlank(edit)) { viewName = "defineNewHoliday"; modelAndView.setViewName(viewName); modelAndView.addObject("formBean", formBean); } else if (StringUtils.isNotBlank(cancel)) { modelAndView.setViewName("redirect:viewHolidays.ftl"); status.setComplete(); } else if (result.hasErrors()) { modelAndView.setViewName("previewHoliday"); } else { HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean); List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds()); this.holidayServiceFacade.createHoliday(holidayDetail, branchIds); viewName = REDIRECT_TO_ADMIN_SCREEN; modelAndView.setViewName(viewName); status.setComplete(); } return modelAndView; }