コード例 #1
0
  @RequestMapping(value = "doedit", method = RequestMethod.POST)
  public String doeditDCTAPById(
      FormDemandeConsoTempsAccPers formDctap, BindingResult bindResult, Model model) {
    User prof = manager.getUserById(formDctap.getProfId());
    if (prof == null)
      bindResult.rejectValue("profId", "required", "Erreur d'identifiant de professeur");

    if (bindResult.hasErrors()) {
      model.addAttribute("lesProfs", manager.getAllProf());
      return "eleve/edit";
    } else {
      User user = UtilSession.getUserInSession();
      DemandeValidationConsoTempsAccPers dctapForUpdate =
          manager.getDVCTAPById(Long.valueOf(formDctap.getId()));
      if (dctapForUpdate.getEtat() == 0 || dctapForUpdate.getEtat() == 4) {

        AccPersonalise acc = new AccPersonalise(null, formDctap.getAccPersNom(), 1, user.getId());
        if (manager.getAPById(formDctap.getAccPersId()) != null) {
          acc = manager.getAPById(formDctap.getAccPersId());
          dctapForUpdate.setAccPers(manager.getAPById(formDctap.getAccPersId()));
        } else {
          manager.addAP(acc);
          dctapForUpdate.setAccPers(manager.getAPByNom(formDctap.getAccPersNom()));
        }

        dctapForUpdate.setDateAction(formDctap.getDateAction());
        dctapForUpdate.setMinutes(formDctap.getMinutes());

        dctapForUpdate.setProf(manager.getUserById(formDctap.getProfId()));
        dctapForUpdate.setDctapModifEleve();
        manager.updateDVCTAP(dctapForUpdate);
      }

      return "redirect:/app/eleve/mesdctap";
    }
  }
コード例 #2
0
  @RequestMapping(value = "edit", method = RequestMethod.GET)
  public String editDCTAPById(
      @RequestParam("id") String id, FormDemandeConsoTempsAccPers formDctap, Model model) {

    // System.out.println("TEST id recu :" + formDctap.getId());

    DemandeValidationConsoTempsAccPers currentDctap = manager.getDVCTAPById(Long.valueOf(id));

    System.out.println("DCTAP : " + currentDctap);

    // valorise le bean de vue avec le dctap courant
    formDctap.setId(currentDctap.getId()); // en provenance d'un champ caché
    formDctap.setDateAction(currentDctap.getDateAction());
    formDctap.setProfId(currentDctap.getProf().getId());
    // formDctap.setProfNom(currentDctap.getProf().getNom());
    formDctap.setIdEleve(currentDctap.getEleve().getId());
    formDctap.setAccPersId(currentDctap.getAccPers().getId());
    formDctap.setMinutes(currentDctap.getMinutes());
    model.addAttribute("minute", currentDctap.getMinutes());
    model.addAttribute("lesProfs", manager.getAllProf());
    model.addAttribute("etat", manager.getDVCTAPById(formDctap.getId()).getEtat());
    model.addAttribute("lesAP", manager.getAllAPForEleve());
    return "eleve/edit";
  }