Package web

Examples of web.FolderForm


  @Override
  protected Object formBackingObject(HttpServletRequest request)
      throws Exception {
    HttpSession session = request.getSession(false);
    if (session == null)
      return new FolderForm();
    FolderForm ff = (FolderForm) session.getAttribute("updatedFF");
    if (ff == null) {
      return new FolderForm();
    }
    return ff;
  }
View Full Code Here


  }

  protected void postProcessPage(HttpServletRequest request, Object command,
      Errors errors, int page) throws Exception {

    FolderForm ff = (FolderForm) command;
    Folder folder = ff.getFolder();
    Promodetail current = folder.getCurrentPromoDetail();
    String delete = request.getParameter("del");
    String edit = request.getParameter("edit");
    String action = request.getParameter("action");
    String todelete = request.getParameter("delCV");

    if (page == 5) {

      if (action != null) {
        // recuperation du multipart
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        MultipartFile fichier = multipartRequest.getFile("data");

        if (fichier.isEmpty()) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "cv.data.obligatoire",
              "Le document est vide!");
          errors.setNestedPath("");
          return;
        }

        String nomDocument = fichier.getOriginalFilename();

        if (!nomDocument.endsWith(".pdf")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Seuls les documents 'pdf' sont autoris�s!");
          errors.setNestedPath("");
          return;
        }

        if (nomDocument.equals("")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Sp�cifiez un chemin !");
          errors.setNestedPath("");
          return;
        }

        String chemin = null;
        Document cv = folder.getPi().getCv();

        if (!cv.getName().equals("")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Vous avez d�ja envoy� un cv: supprimez le avant!");
          errors.setNestedPath("");
          return;
        }

        String id = Generator.getRandomId();
        chemin = request.getSession().getServletContext().getRealPath(
            "/")
            + "uploads/CV/" + id + "_" + nomDocument;
        enregistrer(fichier, chemin);
        cv.setName(id + "_" + nomDocument);
      } else if (todelete != null) {
        System.out.println("DELETING RESUME");
        Document cv = folder.getPi().getCv();
        File f = new File(request.getSession().getServletContext()
            .getRealPath("/")
            + "uploads/CV/" + cv.getName());
        f.delete();
        cv.setName("");
      }

    } else if (page == 3) {
      if (request.getParameter("add") != null) {
        errors.setNestedPath("folder.currentPromoDetail");
        String university = request.getParameter("univs");
        String diplome = request.getParameter("diplomes");
        if (!current.getYear().equals("")) {
          try {
            Integer.parseInt(current.getYear());
          } catch (NumberFormatException nfe) {
            errors.rejectValue("year", "year.invalid",
                "Type incorrect.");
            errors.setNestedPath("");
            return;
          }
        }

        if (!current.getRegistered().equals("")) {
          try {
            Integer.parseInt(current.getRegistered());
          } catch (NumberFormatException nfe) {
            errors.rejectValue("registered", "registered.invalid",
                "Type incorrect.");
            errors.setNestedPath("");
            return;
          }
        }

        if (!current.getQualified().equals("")) {
          try {
            Integer.parseInt(current.getQualified());
          } catch (NumberFormatException nfe) {
            errors.rejectValue("qualified", "qualified.invalid",
                "Type incorrect.");
            errors.setNestedPath("");
            return;
          }
        }

        if (!current.getMark().equals("")) {
          try {
            Float.parseFloat(current.getMark());
          } catch (NumberFormatException nfe) {
            errors.rejectValue("mark", "mark.invalid",
                "Éssayez xx.5.");
            errors.setNestedPath("");
            return;
          }
        }

        if (!current.getRank().equals("")) {
          try {
            Integer.parseInt(current.getRank());
          } catch (NumberFormatException nfe) {
            errors.rejectValue("rank", "rank.invalid",
                "Type incorrect.");
            errors.setNestedPath("");
            return;
          }

        }

        if (current.isInComplete()) {
          errors.setNestedPath("folder");
          errors.rejectValue("promodetails", "promodetails.invalid",
              "Remplissez tous les champs.");
          errors.setNestedPath("");
          return;
        }

        errors.setNestedPath("");

        University u = umng.getUniversity(university);
        Diplome d = dmng.getDiplomes(diplome);

        if (!current.isEmpty()) {
          current.setDiplome(d);
          current.setUniversity(u);
          folder.addPromodetail(current);
        }

      } else if (request.getParameter("adduniv") != null) {
        String nouveau = request.getParameter("newuniv");
        /*
         * It is very difficult to check the validity of variable
         * 'newuniv' Whe just check if 'nouveau' is not empty.
         */
        if (!nouveau.equals("")) {
          University university = new University();
          university.setLabel(nouveau.toUpperCase());
          umng.add(university);
        }
      } else if (request.getParameter("adddegree") != null) {
        String nouveau = request.getParameter("newdegree");
        /*
         * It is very difficult to check the validity of variable
         * 'newdegree' Whe just check if 'nouveau' is not empty.
         */
        if (!nouveau.equals("")) {
          Diplome diplome = new Diplome();
          diplome.setLabel(nouveau.toUpperCase());
          dmng.add(diplome);
        }

      } else if (delete != null) {
        int index = Integer.parseInt(delete);

        List promos = ff.getFolder().getPromodetails();
        ff.getFolder().deletePromodetail(index);
      } else if (edit != null) {
        // folder.setCurrentPromoDetail((Promodetail)folder.getPromodetails().get(Integer.parseInt(edit)));
      }
    }

View Full Code Here

        System.out.println(i);
      }

      List diplomes = dmng.getDiplomes();
      List univs = umng.getUniversities();
      FolderForm folderFormPromoDetails = (FolderForm) command;
      Folder folderPromoDetail = folderFormPromoDetails.getFolder();
      List promos = folder.getPromodetails();
      folder.setNbPromodetails(promos.size());
      model.put("diplomes", diplomes);
      model.put("univs", univs);
      model.put("promos", promos);
View Full Code Here

  }

  @Override
  protected void validatePage(Object command, Errors errors, int page) {
    FolderForm folderForm = (FolderForm) command;
    InputValidator inputValidator = (InputValidator) getValidator();

    switch (page) {
    case 1:
      errors.setNestedPath("folder.pi");
      inputValidator.validatePageOne(folderForm.getFolder().getPi(),
          errors);
      break;
    case 2:
      errors.setNestedPath("folder");
      inputValidator.validatePageTwo(folderForm.getFolder(), errors);
      break;
    default:
      break;
    }
    errors.setNestedPath("");
View Full Code Here

  @Override
  protected Object formBackingObject(HttpServletRequest request)
      throws Exception {
    HttpSession session = request.getSession(false);
    FolderForm ff = (FolderForm)session.getAttribute("updatedFF");
    if (ff == null) {
      return new FolderForm();
    }
    return ff;


  }
View Full Code Here

      folder.setPi(pi);

      folder.setPromodetails(promos);
      folder.majPromodetailPositions();
      folder.setNbPromodetails(promos.size());
      FolderForm ff = new FolderForm();
      ff.setFolder(folder);

      /* debut de la session */
      request.getSession(true);

      request.getSession().setAttribute("updatedFF", ff);
View Full Code Here

  @Override
  protected void postProcessPage(HttpServletRequest request, Object command,
      Errors errors, int page) throws Exception {

    FolderForm ff = (FolderForm) command;
    Folder folder = ff.getFolder();
    PersonalInfo pi = folder.getPi();
    Promodetail current = folder.getCurrentPromoDetail();
    String delete = request.getParameter("del");
    String action = request.getParameter("action");
    String todelete = request.getParameter("delCV");

    if (page == 0) {

      if (!pi.getEmail().equals("")) {

        if (!pimng.emailIsAvailable(pi.getEmail().trim())) {
          errors.setNestedPath("folder.pi");
          errors.rejectValue("email", "email.invalide",
              "Email existant");
          errors.setNestedPath("");
        }
      }

    } else if (page == 4) {

      if (action != null) {
        // recuperation du multipart
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        MultipartFile fichier = multipartRequest.getFile("data");

        if (fichier.isEmpty()) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "cv.data.obligatoire",
              "Le document est vide!");
          errors.setNestedPath("");
          return;
        }

        String nomDocument = fichier.getOriginalFilename();

        if (!nomDocument.endsWith(".pdf")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Seuls les documents 'pdf' sont autorises!");
          errors.setNestedPath("");
          return;
        }

        if (nomDocument.equals("")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Specifiez un chemin !");
          errors.setNestedPath("");
          return;
        }

        String chemin = null;
        Document cv = folder.getPi().getCv();

        if (!cv.getName().equals("")) {
          errors.setNestedPath("folder.pi.cv");
          errors.rejectValue("data", "data.invalid",
              "Vous avez deja envoye un cv: supprimez le avant!");
          errors.setNestedPath("");
          return;
        }

        String id = Generator.getRandomId();
        chemin = request.getSession().getServletContext().getRealPath(
            "/")
            + "uploads/CV/" + id + "_" + nomDocument;
        enregistrer(fichier, chemin);
        cv.setName(id + "_" + nomDocument);
      } else if (todelete != null) {
        Document cv = folder.getPi().getCv();
        File f = new File(request.getSession().getServletContext()
            .getRealPath("/")
            + "uploads/CV/" + cv.getName());
        f.delete();
        cv.setName("");
      }

    } else if (page == 2) {

      if (request.getParameter("add") != null && !errors.hasErrors()) {

        if (folder.getNbPromodetails() == 6) {
          errors.setNestedPath("folder");
          errors.rejectValue("promodetails", "promodetails.invalid",
              "Vous avez deja specifie 6 annees d'etude.");
          errors.setNestedPath("");
          return;
        }

        String university = request.getParameter("univs");
        String diplome = request.getParameter("diplomes");
        if (current.isInComplete()) {
          errors.setNestedPath("folder");
          errors.rejectValue("promodetails", "promodetails.invalid",
              "Remplissez tous les champs.");
          errors.setNestedPath("");
          return;
        }

        University u = umng.getUniversity(university);
        Diplome d = dmng.getDiplomes(diplome);

        if (!current.isEmpty()) {
          current.setDiplome(d);
          current.setUniversity(u);
          folder.addPromodetail(current);
        }

      } else if (request.getParameter("adduniv") != null) {
        String nouveau = request.getParameter("newuniv");
        /*
         * It is very difficult to check the validity of variable
         * 'newuniv' Whe just check if 'nouveau' is not empty.
         */
        if (!nouveau.equals("")) {
          University university = new University();
          university.setLabel(nouveau.toUpperCase());
          umng.add(university);
        }
      } else if (request.getParameter("adddegree") != null) {
        String nouveau = request.getParameter("newdegree");
        /*
         * It is very difficult to check the validity of variable
         * 'newdegree' Whe just check if 'nouveau' is not empty.
         */
        if (!nouveau.equals("")) {
          Diplome diplome = new Diplome();
          diplome.setLabel(nouveau.toUpperCase());
          dmng.add(diplome);
        }

      } else if (delete != null) {
        int index = Integer.parseInt(delete);
        ff.getFolder().deletePromodetail(index);
      }
    }

  }
View Full Code Here

      throws Exception {
    HttpSession session = request.getSession(false);
    if (session == null) {
      request.getSession(true);
    }
    return new FolderForm();
  }
View Full Code Here

    return model;

  }

  protected void validatePage(Object command, Errors errors, int page) {
    FolderForm folderForm = (FolderForm) command;
    InputValidator inputValidator = (InputValidator) getValidator();

    switch (page) {
    case 0:
      errors.setNestedPath("folder.pi");
      inputValidator.validatePageOne(folderForm.getFolder().getPi(),
          errors);
      logger.info("WizardCTRL - validatePageOne() was called");
      break;
    case 1:
      errors.setNestedPath("folder");
      inputValidator.validatePageTwo(folderForm.getFolder(), errors);

      logger.info("WizardCTRL - validatePageTwo() was called");
      break;
    case 2:
      errors.setNestedPath("folder.currentPromoDetail");
      inputValidator.validatePageThree(folderForm.getFolder()
          .getCurrentPromoDetail(), errors);
      logger.info("WizardCTRL - validatePageThree() was called");
      break;
    }
    errors.setNestedPath("");
View Full Code Here

TOP

Related Classes of web.FolderForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.