コード例 #1
0
 public void salvarArquivo() throws IOException {
   UploadedFile arq = file;
   if (arq != null) {
     saidaFinanceiro.setArquivo(new Arquivo());
     saidaFinanceiro.getArquivo().setDescricao(arq.getFileName());
     saidaFinanceiro.getArquivo().setContentType(arq.getContentType());
     saidaFinanceiro.getArquivo().setTamanho(arq.getSize());
     saidaFinanceiro.getArquivo().setConteudo(arq.getContents());
   }
 }
コード例 #2
0
  public void edicaoImagemProdutoHandler(FileUploadEvent event) throws IOException {

    Fotos imagem = new Fotos();

    if (event != null) {
      UploadedFile up = event.getFile();

      imagem.setNomeFoto(FileUploadUtils.getSomenteNomeArquivo(up.getFileName()));
      imagem.setExtensaoFoto(FileUploadUtils.getSomenteExtensaoArquivo(up.getFileName()));
      imagem.setTamFoto((double) up.getSize());
      imagem.setContentType(up.getContentType());
      imagem.setFoto(up.getContents());

      getProduto().setFoto(imagem);
      getSessaoAtual()
          .setAttribute(ServletExibicaoTemporariaEdicaoProdutos.IMAGEM_A_SER_EDITADA, imagem);
    }
  }
コード例 #3
0
ファイル: ClientBean.java プロジェクト: mcelio/work-02
  /**
   * Methos does the upload and compilation process, inclusing the web service call
   *
   * @param uploadedFile
   */
  private void doCompilation(UploadedFile uploadedFile) {
    logger.error("Start the compilation process");
    // check if the file is null or not
    if (uploadedFile != null) {
      try {
        // web service call
        Compilation result = compileProjectService.compileProject(uploadedFile.getContents());
        // the result to the compilation list
        if (result != null) {
          if (getList() == null) {
            list = new ArrayList<Compilation>();
          }
          list.add(result);
        }

      } catch (Exception e) {
        logger.error("Error: " + e);
        FacesMessage message =
            new FacesMessage(
                "Error", "Unexpected error occurred qhen calling the web service provider.");
        FacesContext.getCurrentInstance().addMessage(null, message);
      }
    }
  }
コード例 #4
0
 public void uploadPicture(FileUploadEvent event) {
   UploadedFile picture = event.getFile();
   byte[] pictureByte = picture.getContents();
   advert.setPicture(pictureByte);
 }
コード例 #5
0
ファイル: RecipeBean.java プロジェクト: nymphel/sm504
 public void upload(FileUploadEvent event) {
   UploadedFile file = event.getFile();
   if (file != null) {
     recipe.setPhoto(file.getContents());
   }
 }
コード例 #6
0
ファイル: NotesBean.java プロジェクト: djionang/SAGES
  /**
   * Enregistrer des notes a partir de fichier excel (.xls) importés
   *
   * @return la chaine de navigation pour la suite des opérations
   */
  public String enregistrerImport() {
    if (fichierImport != null && fichierImport.getSize() != 0) {

      ByteArrayInputStream stream = new ByteArrayInputStream(fichierImport.getContents());

      try {
        POIFSFileSystem fs = new POIFSFileSystem(stream);
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFRow row = null;
        HSSFCell cellmat = null;
        HSSFCell cellnote = null;
        int numcell = 0;

        // recupere tous les eleves figurant dans le fichier importé
        for (Iterator<Row> rowIt = sheet.rowIterator(); rowIt.hasNext(); ) {

          if (numcell >= 4) {
            row = (HSSFRow) rowIt.next();
            cellnote = row.getCell(5);

            cellmat = row.getCell(2);
            if (cellmat != null && cellnote != null) {

              // nous verifions ici si la note est comprise dans la fourchette voulue
              if ((float) cellnote.getNumericCellValue() > 20
                  || (float) cellnote.getNumericCellValue() < 0) {
                Repertoire.addMessageerreur(
                    "vous avez entrez une ou plusieurs note(s) qui n'est (sont) pas comprise en zero et 20");
                return "";
              }
              // fonction qui take le matricule et la note dun eleve pour mettre dans le bean
              insererNoteEleve(
                  cellmat.getStringCellValue(), (float) cellnote.getNumericCellValue());
            } else {
              if (cellmat != null && cellnote == null) {

                // fonction qui take le matricule et la note dun eleve pour mette dans le bean
                insererNoteEleve(cellmat.getStringCellValue(), (float) 0);
              }
            }
          } else {
            numcell++;
            rowIt.next();
          }
        } // End for

      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      try {
        this.service.enregistrerNotes(compositions, codeevaluation);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    Repertoire.addMessageinfo("Notes enregistrées");
    return OperationResults.navWithParam(
        "visualiserNotes", "codeevaluation", String.valueOf(codeevaluation));
  }