コード例 #1
0
  @RequestMapping(value = "/addCustomer.htm", method = RequestMethod.POST)
  public ModelAndView addCustomer(
      @ModelAttribute("customer") @Valid Customer customer,
      BindingResult result,
      SessionStatus status) {

    ModelAndView mav = new ModelAndView();

    if (result.hasErrors()) {
      LOGGER.info("Error occurred in AddCustomer form ");
      mav.setViewName("AddCustomer");
      mav.addObject("customer", customer);
      return mav;
    } else {
      int resultValue = 0;
      resultValue = customerService.addCustomer(customer);
      if (StringUtils.isBlank(customer.getCustomerID()))
        customer.setCustomerID(Integer.toString(resultValue));

      LOGGER.info("Customer added !! ");
      mav.setViewName("AddCustomer");
      // mav.addObject("resultValue", resultValue);
      mav.addObject("customer", customer);
      return mav;
    }
  }
コード例 #2
0
  @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;
    }
  }
コード例 #3
0
  @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;
  }
コード例 #4
0
 @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;
 }
コード例 #5
0
 @RequestMapping(value = "/openCustomer.htm")
 public ModelAndView openCustomer(@RequestParam("id") String cutomerId) throws Exception {
   ModelAndView mav = new ModelAndView();
   LOGGER.info("cutomerId: " + cutomerId);
   try {
     Customer cust = customerService.openCustomer(cutomerId);
     List<Policy> policies = policyService.getCustomerPolicies(cutomerId);
     mav.setViewName("AddCustomer");
     mav.addObject("policies", policies);
     mav.addObject("customer", cust);
     return mav;
   } catch (Exception e) {
     mav.setViewName("Exception");
     mav.addObject("exceptionReason", e.getMessage());
     return mav;
   }
 }
コード例 #6
0
  @RequestMapping(value = "/updateCustomer.htm", method = RequestMethod.POST)
  public ModelAndView updateCustomer(
      @ModelAttribute("customer") @Valid Customer customer,
      BindingResult result,
      SessionStatus status) {

    ModelAndView mav = new ModelAndView();

    if (result.hasErrors()) {
      LOGGER.info("Error occurred in AddCustomer form ");
      mav.setViewName("AddCustomer");
      mav.addObject("customer", customer);
      return mav;
    } else {
      int resultValue = 0;
      resultValue = customerService.updateCustomer(customer);
      LOGGER.info("Customer updated !! ");
      mav.setViewName("AddCustomer");
      mav.addObject("resultValue", resultValue);
      mav.addObject("customer", customer);
      return mav;
    }
  }