• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UploadItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.richfaces.model.UploadItem的典型用法代码示例。如果您正苦于以下问题:Java UploadItem类的具体用法?Java UploadItem怎么用?Java UploadItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UploadItem类属于org.richfaces.model包,在下文中一共展示了UploadItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: uploadListener

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void uploadListener(UploadEvent event) {
    UploadItem item = event.getUploadItem();
    if (item.isTempFile()) {
    } else {
        try {
            String fname = item.getFileName();
            int i = fname.lastIndexOf('/');
            if (i == -1) {
                i = fname.lastIndexOf('\\');
            }
            if (i != -1) {
                fname = fname.substring(i);
            }

            FileOutputStream fout = new FileOutputStream(getFwPath() + fname);
            fout.write(item.getData());
            fout.close();
        } catch (Exception e) {
            // TODO: handle exception
        }

    }
}
 
开发者ID:navisidhu,项目名称:libreacs,代码行数:24,代码来源:SoftwaresBean.java


示例2: atualizaLogotipoEmpresa

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
 * @param uploadedFile
 * @return
 */
protected void atualizaLogotipoEmpresa(UploadItem uploadItem) {
	String contentType = uploadItem.getContentType();
	byte[] data = getData(uploadItem);

	ByteArrayInputStream bais = new ByteArrayInputStream(data);
	
	BufferedImage bufferedImage;
	try {
		bufferedImage = ImageIO.read(bais);
	} catch (IOException e) {
		throw new JazzRuntimeException("Erro ao tentar ler imagem contida no array de bytes",e);
	}
	
	getEmpresaVO().getLogos().clear();
	
	ImageLogoVO imageLogoVO = new ImageLogoVO();
	imageLogoVO.setImage(bufferedImage);
	
	getEmpresaVO().getLogos().add(imageLogoVO);

}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:27,代码来源:ConfiguracoesJSFBean.java


示例3: actionHandleFileUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Action
* @param event
* @throws IOException 
*/
public void actionHandleFileUpload(UploadEvent event) throws IOException {  
	QuestionVO editQuestion = getEditQuestion();
	
	if(editQuestion==null){
		return;
	}
	
	if(editQuestion.getImageVOs().size()>=QuestionnaireJSFBean.MAX_IMAGES_PER_QUESTION){
		addMessage(FacesMessage.SEVERITY_ERROR, "Não é possível carregar mais de "+QuestionnaireJSFBean.MAX_IMAGES_PER_QUESTION+" imagens por questão!", "");
		return;
	}
	

	List<UploadItem> files = event.getUploadItems();
	
	for (UploadItem uploadItem : files) {
		if(isImage(uploadItem)){
			attachQuestionImage(editQuestion, uploadItem);
		}
}  	
	
  addMessage(FacesMessage.SEVERITY_INFO, "Imagens carregadas com sucesso!", "");
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:29,代码来源:QuestionnaireJSFBean.java


示例4: isImage

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * @param uploadItem
 * @return
 */
protected boolean isImage(UploadItem uploadItem) {
	String contentType=uploadItem.getContentType();
	
	String imageTypes = 
	
	"#"+"image/gif"+"#"+
	"#"+"image/jpeg"+"#"+
	"#"+"image/png"+"#"+
	"#"+"image/x-png"+"#"+
	"#"+"image/pjpeg"+"#"+
	"#"+"image/tiff"+"#"+
	"#"+"image/bmp"+"#";
	
	return imageTypes.contains(contentType);
	
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:21,代码来源:QuestionnaireJSFBean.java


示例5: onReadAvailableLanguages

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void onReadAvailableLanguages(ActionEvent event) throws IOException {
    this.availableLanguages.clear();

    for (UploadItem item : this.uploadedConcepts) {
        byte[] fileData;
        if (item.isTempFile()) {
            fileData = FileUtils.readFileToByteArray(item.getFile());
        } else {
            fileData = item.getData();
        }

        String xml = new String(fileData);

        String[] languages = metaDataFacade.getLanguagesAvailableForImport(
                xml);

        for (String lang : languages) {
            lang = lang.replaceAll("-", "_");
            Locale locale = LocaleUtils.toLocale(lang);
            this.availableLanguages.put(locale.getDisplayLanguage(), lang);
        }
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:24,代码来源:Concepts.java


示例6: onImport

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for importing the uploaded subject files.
 *
 * @param event Event that invoked the handler
 * @throws IOException If any of the uploaded files could not be read
 */
public void onImport(ActionEvent event) throws IOException {
    int imported = 0;
    for (UploadItem item : this.uploadedConcepts) {

        byte[] fileData;
        if (item.isTempFile()) {
            fileData = FileUtils.readFileToByteArray(item.getFile());
        } else {
            fileData = item.getData();
        }

        String xml = new String(fileData);

        if (getImportLanguage() != null) {
            imported += metaDataFacade.importKnowledgeItem(xml,
                    getImportLanguage());
        }
    }

    JsfUtils.createMessage("frmSubjects", FacesMessage.SEVERITY_INFO, Bundle.i18n.name(),
            "Concepts_X_SUBJECTS_IMPORTED", new Object[]{imported});
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:29,代码来源:Concepts.java


示例7: onUploadRendition

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for uploading a new {@link Rendition} to the
 * {@link MediaItem}
 *
 * @param event Event that invoked the handler
 * @throws IOException If the file could not be uploaded
 */
public void onUploadRendition(UploadEvent event) throws IOException {
    UploadItem item = event.getUploadItem();
    LOG.log(Level.FINE, "Uploading {0}", item.getFileName());

    MediaItemRendition mediaItemRendition;
    try {
        mediaItemRendition = catalogueFacade.create(item.getFile(),
                getSelectedMediaItem(),
                getUploadRendition(),
                item.getFileName(),
                item.getContentType(),
                true);
        LOG.log(Level.FINE, "New media item rendition created: {0}", mediaItemRendition.getId());
    } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Could not create media item rendition. {0}", ex.getMessage());
        LOG.log(Level.FINEST, "", ex);
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:26,代码来源:MediaItemDetails.java


示例8: onUploadReplaceRendition

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for uploading a replacement for an existing
 * {@link Rendition}.
 *
 * @param event Event that invoked the handler
 * @throws IOException If the file could not be uploaded
 */
public void onUploadReplaceRendition(UploadEvent event) throws IOException {
    UploadItem item = event.getUploadItem();
    LOG.log(Level.FINE, "Uploading {0}", item.getFileName());

    MediaItemRendition mediaItemRendition;
    try {
        mediaItemRendition = catalogueFacade.update(item.getFile(),
                item.getFileName(),
                item.getContentType(),
                getSelectedRendition(),
                true);
        LOG.log(Level.FINE, "Media item rendition #{0} was updated.", mediaItemRendition.getId());
    } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Could not create media item rendition. {0}", ex.getMessage());
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:24,代码来源:MediaItemDetails.java


示例9: prepararArquivoParaEnviar

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Prepara o UploadItem com o arquivo de producao.xlf
 */
public void prepararArquivoParaEnviar(){
 	String nome_arquivo = "producao.xfl";
 	String caminho = Constantes.CAMINHO_ABSOLUTO_ARQUIVOS_CARGA + nome_arquivo;
	java.io.File file = new java.io.File(caminho);
	
	byte[] b = new byte[(int) file.length()];
	
	try {
		FileInputStream fileInputStream = new FileInputStream(file);
		fileInputStream.read(b);
	} catch (FileNotFoundException e) {
		System.out.println("File Not Found.");
		e.printStackTrace();
	} catch (IOException e1) {
		System.out.println("Error Reading The File.");
		e1.printStackTrace();
	}
	
	itemParaEnvio = new UploadItem(nome_arquivo,(int)file.length(),"xfl",b);
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:24,代码来源:CargaEstudoIncluiModelagemFuzzy.java


示例10: salvarArquivoModelagemFuzzy

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Metodo resposavel por salvar os dados de um arquivo de modelagem fuzzy(.xfl).
 * Chama o motor de inferencia e utiliza o metodo salvarArquivoModelagem passando o caminho do arquivo
 * e os dados a serem incluidos.
 * Se o metodo anterior jogar uma motorInferencia exception ele a converte para uma applicationexception e joga para cima.
 * Com isso a parte que lida com a gravacao dos dados em arquivo fica ligada apenas ao motorinferencia.
 * 
 */
@Transacional
public void salvarArquivoModelagemFuzzy(UploadItem item) throws AplicacaoException {

   	String caminhoDoArquivo = Constantes.CAMINHO_ABSOLUTO_MODELAGEM_UPLOADFILE;

   	System.out.println("Destino do arquivo="+caminhoDoArquivo);
   	System.out.println("original="+item.getFileName());
   	
   	String filePathName = item.getFileName();
   	String fileName = "";
   	StringTokenizer st = new StringTokenizer(filePathName,"\\");    	
   	while(st.hasMoreElements()){
   		fileName = st.nextToken();
   	}
   	
   	
   	caminhoDoArquivo = caminhoDoArquivo  + fileName;
   	
   	try {
		MotorInferencia.salvarArquivoModelagem(caminhoDoArquivo, item.getData());
	} catch (MotorInferenciaException e) {
		throw new AplicacaoException(e.getMessage());
	}
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:33,代码来源:ModelagemFuzzyAppService.java


示例11: incluiComUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Inclui uma modelagem fuzzy junto com o arquivo que foi feito upload, dessa forma ambos os passos ficam ligados.
 * Apois incluir a modelagem fuzzy desejada no BD, ele tenta salvar o arquivo em si no sistema.
 * Se um dos passos falhar ele volta sem deixar lixo.
 * @param modelagemFuzzy
 * @param item
 * @return
 * @throws AplicacaoException
 */
@Transacional
public long incluiComUpload(ModelagemFuzzy modelagemFuzzy, UploadItem item) throws AplicacaoException {
	
	
	long retorno = -1;
	
	try {
		modelagemFuzzyDAO.recuperaModelagemFuzzyPeloNome(modelagemFuzzy.getNomeModelagemFuzzy());
		throw new AplicacaoException("modelagem.CODIGO_MODELAGEM_EXISTENTE");
	} catch (ObjetoNaoEncontradoException e) {		
			retorno = modelagemFuzzyDAO.inclui(modelagemFuzzy).getId();		
			salvarArquivoModelagemFuzzy(item);
	}		

	return retorno;
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:26,代码来源:ModelagemFuzzyAppService.java


示例12: uploadListener

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void uploadListener(UploadEvent event) {
    UploadItem item = event.getUploadItem();

    System.out.println("item : '" + item);
    System.out.println("File : '" + item.getFileName() + "' was uploaded");
    System.out.println("Content-type : '" + item.getContentType());
    System.out.println("Data : '" + item.getData());
    System.out.println("IsTemporary : '" + item.isTempFile());
    //        System.out.println("Length : '" + item.getData().length);
    System.out.println("javaFile : '" + item.getFile());

    String fname = item.getFileName();
    int i = fname.lastIndexOf('/');
    if (i == -1) {
        i = fname.lastIndexOf('\\');
    }
    if (i != -1) {
        fname = fname.substring(i);
    }
    fname = getFwPath() + fname;
    if (item.isTempFile()) {
        try {
            File tmpfile = item.getFile();
            if (!tmpfile.renameTo(new File(fname))) {
                setErrorMessage("Failed to rename file '" + tmpfile.getCanonicalPath() + "' to '" + fname + "'");
            }
        } catch (Exception ex) {
            setErrorMessage(ex.getMessage());
        }
    } else {
        try {
            FileOutputStream fout = new FileOutputStream(fname);
            fout.write(item.getData());
            fout.close();
        } catch (Exception e) {
            setErrorMessage(e.getMessage());
        }

    }
}
 
开发者ID:navisidhu,项目名称:libreacs,代码行数:41,代码来源:SoftwareJsfBean.java


示例13: processUploadFiles

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
  * Inicia processamento de cada arquivo enviado via upload
  * @param files
  */
public void processUploadFiles(List<UploadItem> files) {
	for (UploadItem uploadItem : files) {
		
		//transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
 		readImagesFromFile(uploadItem);
 		
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:13,代码来源:EventProcJSFBean.java


示例14: getrelatorioVO

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * 
 * @param uploadItem
 * @return
 */
protected RelatorioVO getrelatorioVO(UploadItem uploadItem) {
	byte[] data = getData(uploadItem);
	
	
	JRFileVO jrFileVO = new JRFileVO();
	jrFileVO.setJasperReport(data);
	
	RelatorioVO relatorioVO = new RelatorioVO();
	relatorioVO.getJrFileVOs().add(jrFileVO);

	String datePart = LABEL_DTFORMAT.format(new Date());
	relatorioVO.setDescription("Modelo de Prova ("+datePart+")");
	return relatorioVO;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:ConfiguracoesJSFBean.java


示例15: actionLogoImgUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Processa upload de imagem contendo novo logotipo da empresa
* @param event
*/
public void actionLogoImgUpload(UploadEvent event) {  
	List<UploadItem> files = event.getUploadItems();
	for (UploadItem uploadItem : files) {
	//transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
	atualizaLogotipoEmpresa(uploadItem);
}
FacesContext context = FacesContext.getCurrentInstance();					
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Imagens carregadas com sucesso!", "Imagens carregadas com sucesso!"));
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:14,代码来源:ConfiguracoesJSFBean.java


示例16: enviarArquivo

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
   * Este m�todo � respons�vel pelo upload de arquivos, perceba que este
   * metodo esta ligado a um fileUploadListener, ou seja, a um listener de aplica�ao,
   * por isso nao foi necessario passar um atributo do tipo File, pois o proprio
   * atributo fileUploadListener encarrega-se de receber um objeto do tipo File. 
   * 
   * chama o metodo incluiComUpload() de modelagemFuzzyService.
   * 
   * @author felipe.arruda
   * @param evento
   * 
   */
  public void enviarArquivo(UploadEvent evento) {

  	
  	UploadItem item = evento.getUploadItem();
  	
      try {        	
      	dataCriacao = new Date();
      	modelagemFuzzyCorrente.setDataCriacao(DataUtil.dateToCalendar(dataCriacao));
      	modelagemFuzzyCorrente.setNomeArquivo(item.getFileName());
      	modelagemFuzzyCorrente.setAutor(sessaoUsuarioCorrente.getUsuarioLogado().getNome());
      	modelagemFuzzyCorrente.setFinalidadeModelagem(comboModelagemFuzzy.getObjetoSelecionado());
      	modelagemFuzzyService.incluiComUpload(modelagemFuzzyCorrente, item);			
      	
	File file = new File();
       file.setLength(item.getData().length);
       file.setName(item.getFileName());
       file.setData(item.getData());
       files.add(file);
       
       uploadsAvailable--;
	listaDeModelagemFuzzys = null;
	messenger = true;
      	
} catch (AplicacaoException e) {
	
	valorDaMensagem=e.getMessage();
	messenger = false;
}

  }
 
开发者ID:dayse,项目名称:gesplan,代码行数:43,代码来源:ModelagemFuzzyActions.java


示例17: carregaModelo

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/*** Métodos da classe ***/

public void carregaModelo(UploadEvent event) throws Exception {
	UploadItem item = event.getUploadItem();
	relatorio.setTamanhoArquivo(item.getData().length);
	relatorio.setArquivo(item.getFileName());
	relatorio.setDados(item.getData());
}
 
开发者ID:herculeshssj,项目名称:imobiliariaweb,代码行数:9,代码来源:RelatorioController.java


示例18: carregaFoto

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void carregaFoto(UploadEvent event) throws Exception {
	UploadItem item = event.getUploadItem();
	foto = new Foto();
	foto.setTamanho(item.getData().length);
	foto.setArquivo(item.getFileName());
	foto.setDados(item.getData());
	ImageIcon temp = new ImageIcon(item.getData());
	foto.setLargura(temp.getIconWidth());
	foto.setAltura(temp.getIconHeight());
	listaFoto.add(foto);
	contaArquivos--;
}
 
开发者ID:herculeshssj,项目名称:imobiliariaweb,代码行数:13,代码来源:ImovelController.java


示例19: actionHandleFileUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Action
* @param event
*/
public void actionHandleFileUpload(UploadEvent event) {  
	List<UploadItem> files = event.getUploadItems();
	processUploadFiles(files);
  addMessage(FacesMessage.SEVERITY_INFO, "Imagens carregadas com sucesso!", "");
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:10,代码来源:EventProcJSFBean.java


示例20: handleUploadRelatorio

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Processa upload do arquivo jasper inserindo-o no relatório selecionado
* @param event
*/
public void handleUploadRelatorio(UploadEvent event) {  
	
	List<UploadItem> files = event.getUploadItems();
	
	for (UploadItem uploadItem : files) {
	
		byte[] data = getData(uploadItem);//espera um jasper. Já filtrado no componentes rich:fileupload.
	
	JRFileVO jrFileVO = getJrUpload();
	jrFileVO.setJasperReport(data);
	
	String datePart = LABEL_DTFORMAT.format(new Date());

	RelatorioVO relatorioVO = getSelectedRelatorio();
	relatorioVO.getJrFileVOs().add(jrFileVO);
}
	
FacesContext context = FacesContext.getCurrentInstance();					
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Arquivos carregados com sucesso!", "Arquivos carregados com sucesso!"));
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:25,代码来源:ConfiguracoesJSFBean.java



注:本文中的org.richfaces.model.UploadItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ImageRaster类代码示例发布时间:2022-05-22
下一篇:
Java ExceptionUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap