示例#1
0
  @RequestMapping(value = "/contact/edit", method = RequestMethod.GET)
  public String edit(@RequestParam("id") int id, Model model) throws ParseException {
    Constant.clearErrorList();

    System.out.println("EditController: Passing through... ");

    Contact contact = ContactsDAO.readContact(id);
    System.out.println("Edit Contact : " + contact);
    if (contact == null) {
      Constant.addError("Le contact n°" + id + " n'existe pas !");
      return "/WEB-INF/views/list.jsp";
    }

    List<Adresse> adresses = ContactsDAO.readAllAdresse(id);

    model.addAttribute("contact", contact);
    model.addAttribute("adresses", adresses);
    model.addAttribute("user_action", "edit");

    Calendar cal = Calendar.getInstance();
    cal.setTime(contact.getDate());
    model.addAttribute("dayParam", String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
    model.addAttribute("monthParam", convertMonth(cal.get(Calendar.MONTH) + 1));
    model.addAttribute("yearParam", cal.get(Calendar.YEAR));

    return "/WEB-INF/views/create.jsp";
  }
示例#2
0
  @RequestMapping(value = "/contact/adresse/edit")
  public String editAdresse(
      @ModelAttribute("contact") Contact contact,
      @RequestParam("id") int idContact,
      @RequestParam("idAdresse") int idAdresse,
      Model model)
      throws ParseException {

    System.out.println("EditController ADRESSE: Passing through... ");
    contact = ContactsDAO.readContact(idContact);
    System.out.println("Edit Contact : " + contact);
    if (contact == null) {
      Constant.addError("Le contact n°" + idContact + " n'existe pas !");
      return "redirect:/list";
    }

    Adresse adresse = ContactsDAO.readAdresse(idContact, idAdresse);
    model.addAttribute("contact", contact);
    model.addAttribute("adresse", adresse);
    model.addAttribute("user_action", "update");
    model.addAttribute("errors", Constant.errorList);

    return "/WEB-INF/views/adresseform.jsp";
  }
示例#3
0
 private String convertMonth(int monthParam) {
   Constant.fillDateIntToStringMap();
   return Constant.dateIntToStringMap.get(monthParam);
 }