@RequestMapping(value = "/searchCustomer.htm") public ModelAndView showSearchCustomerForm(Model model) { SearchCustomerCriteria searchCustomerCriteria = new SearchCustomerCriteria(); ModelAndView mav = new ModelAndView(); List<Customer> customers = customerService.searchCustomers(searchCustomerCriteria); mav.addObject("customerList", customers); mav.setViewName("SearchCustomer"); mav.addObject("searchCustomerCriteria", searchCustomerCriteria); return mav; }
@RequestMapping(value = "/searchCustomer.htm", method = RequestMethod.POST) public ModelAndView searchCustomer( @ModelAttribute("searchCustomerCriteria") @Valid SearchCustomerCriteria searchCustomerCriteria, BindingResult result, SessionStatus status) { ModelAndView mav = new ModelAndView(); List<Customer> customers = customerService.searchCustomers(searchCustomerCriteria); mav.setViewName("SearchCustomer"); mav.addObject("customerList", customers); return mav; }
@RequestMapping(value = "/deleteCustomer.htm", method = RequestMethod.POST) public ModelAndView deleteCustomer( @ModelAttribute("searchCustomerCriteria") SearchCustomerCriteria searchCustomerCriteria, BindingResult result, SessionStatus status) throws Exception { ModelAndView mav = new ModelAndView(); try { if (result.hasErrors()) { LOGGER.info("Error occurred in delete customer"); mav.setViewName("SearchCustomer"); mav.addObject("customerList", null); return mav; } else { // int resultValue = 0; LOGGER.info("customer ID RECEIVED :" + searchCustomerCriteria.getCustomerID()); // resultValue = customerService.deleteCustomer(searchCustomerCriteria.getCustomerID()); customerService.deleteCustomer(searchCustomerCriteria.getCustomerID()); LOGGER.info("Customer deleted !! "); List<Customer> customers = customerService.searchCustomers(searchCustomerCriteria); mav.setViewName("SearchCustomer"); mav.addObject("customerList", customers); return mav; } } catch (ServiceException e) { LOGGER.info("ServiceException in delete customer :" + e.getMessage()); // ExceptionMessage exceptionMessage = new ExceptionMessage(); // exceptionMessage.setExceptionReason(e.getMessage()); mav.setViewName("Exception"); mav.addObject("exceptionReason", e.getMessage()); return mav; } catch (Exception e) { LOGGER.info("Exception in delete customer :" + e.getMessage()); /* ExceptionMessage exceptionMessage = new ExceptionMessage(); exceptionMessage.setExceptionReason(e.getMessage()); */ mav.setViewName("Exception"); mav.addObject("exceptionReason", e.getMessage()); return mav; } }