当前位置: 首页>>代码示例>>Java>>正文


Java StreamedContent类代码示例

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


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

示例1: downloadFile

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent downloadFile(File file) {
    //define content
    String mimeType;
    if (file.getName().endsWith("png")) {
        mimeType = "image/png";
    } else if (file.getName().endsWith("jpg") || file.getName().endsWith("jpeg")) {
        mimeType = "image/jpeg";
    } else if (file.getName().endsWith("gif")) {
        mimeType = "image/gif";
    } else {
        mimeType = "application/octet-stream";
    }
    try {
        return new DefaultStreamedContent(new FileInputStream(file), mimeType, file.getName());
    } catch (FileNotFoundException ex) {
        LOG.log(Level.SEVERE, null, ex);
    }
    return null;
}
 
开发者ID:vodev,项目名称:vocloud,代码行数:20,代码来源:JobDetailsBean.java

示例2: getListaFile

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getListaFile() {
    try {
        if(turma == null){
            addMessage(getSeverityWarn(),"Por favor selecione a turma!");
            return null;
        }
        InputStream inputStream = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/lista_ata_assinatura.jrxml");
        HashMap<String, Object> map  = new HashMap<String, Object>();
        map.put("COD_TURMA", turma.getId());
        SessionFactoryImplementor factoryImplementor = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
        map.put("REPORT_CONNECTION",factoryImplementor.getConnectionProvider().getConnection());
        StringBuilder nome = new StringBuilder("lista_ata_");
        nome.append(turma.getNome().replaceAll(" ", "_"));
        nome.append(".pdf");
        StreamedContent streamedContent = new DefaultStreamedContent(new ByteArrayInputStream(ReportUtil.reportToPDF(null, inputStream, map)), "application/pdf", nome.toString());
        return streamedContent;
    } catch (Exception ex) {
        addMessage(getSeverityError(),"Erro ao emitir arquivo com senhas! Detalhes: "+ex.getMessage());
        Logger.getLogger(EmissaoReportsBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:dsalinux,项目名称:web-ifad,代码行数:23,代码来源:EmissaoReportsBean.java

示例3: getFichaAvaliacaoDocenteFile

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getFichaAvaliacaoDocenteFile() {
    try {
        InputStream inputStream = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/ficha_avaliacao_docente.jrxml");
        HashMap<String, Object> map  = new HashMap<String, Object>();
        InputStream isSubReport = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/media_respostas_avaliadas_subreport.jrxml");
        map.put("SUBREPORT_DIR", ReportUtil.compileReport(isSubReport));
        SessionFactoryImplementor factoryImplementor = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
        map.put("REPORT_CONNECTION",factoryImplementor.getConnectionProvider().getConnection());
        StringBuilder nome = new StringBuilder("ficha_avaliacao_docente_");
        nome.append(new SimpleDateFormat("yyyy_MM_dd").format(new Date()));
        nome.append(".pdf");
        StreamedContent streamedContent = new DefaultStreamedContent(new ByteArrayInputStream(ReportUtil.reportToPDF(null, inputStream, map)), "application/pdf", nome.toString());
        return streamedContent;
    } catch (Exception ex) {
        addMessage(getSeverityError(),"Erro ao emitir arquivo com senhas! Detalhes: "+ex.getMessage());
        Logger.getLogger(EmissaoReportsBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:dsalinux,项目名称:web-ifad,代码行数:20,代码来源:EmissaoReportsBean.java

示例4: getBackup

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getBackup() {
    List<String> command = new ArrayList<String>();
    command.add("mysqldump");
    command.add("--default_character_set=utf8");
    command.add("--single-transaction");
    command.add("-u" + USERNAME);
    command.add("-p" + PASSWORD);
    command.add(DATABASE);
    try {
      ProcessBuilder builder = new ProcessBuilder(command).redirectErrorStream(
              true);
      Process process = builder.start();
//            process.waitFor();
      InputStream inputStream = process.getInputStream();
      StreamedContent backupContent = new DefaultStreamedContent(inputStream,
              "application/sql", BACKUP_FILENAME);
      return backupContent;
    } catch (Exception ex) {
      logger.log(Level.SEVERE, null, ex);
      return null;
    }
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:23,代码来源:MySQLAccess.java

示例5: streamAlternativeImg

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
/**
 * @param criterionCoordinateVO
 * @param payloadVO
 * @return
 */
protected StreamedContent streamAlternativeImg(CriterionCoordinateVO criterionCoordinateVO, PayloadVO payloadVO) {
	StreamedContent streamedContent;
	
	AbstractImageVO imageVO = payloadVO.getImageVO();
	streamedContent = toStreamedContent(imageVO.getImage());
	return streamedContent;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:13,代码来源:CriterionDetailDTO.java

示例6: getStreamedPhoto

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
/**
 * Can be used to render a image in the view with some image data
 * 
 * @param data
 *            array of bytes with image data
 * @return StreamedContent
 */
public StreamedContent getStreamedPhoto(byte[] data) {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent(FacesContext.getCurrentInstance()
				.getExternalContext()
				.getResourceAsStream("/static/img/default-image.png"));
		// return new DefaultStreamedContent();
	} else {
		if (data != null) {
			return new DefaultStreamedContent(
					new ByteArrayInputStream(data));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
开发者ID:machadolucas,项目名称:watchout,代码行数:27,代码来源:PlayerSessionBean.java

示例7: getStreamedInsuranceIcon

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getStreamedInsuranceIcon() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		String id = context.getExternalContext().getRequestParameterMap()
				.get("id");
		byte[] image = null;
		for (Insurances in : insurances) {
			if (in.getIdinsurances().toString().equals(id)) {
				image = in.getIcon();
				break;
			}
		}
		if (image != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					image));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
开发者ID:machadolucas,项目名称:watchout,代码行数:26,代码来源:GameBean.java

示例8: getStreamedIcon

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getStreamedIcon() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		if (bean.getIcon() != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					bean.getIcon()));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
开发者ID:machadolucas,项目名称:watchout,代码行数:17,代码来源:InsurancesBean.java

示例9: getStreamedPhoto

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getStreamedPhoto() {
	FacesContext context = FacesContext.getCurrentInstance();

	if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
		return new DefaultStreamedContent();
	} else {
		if (bean.getPhoto() != null) {
			return new DefaultStreamedContent(new ByteArrayInputStream(
					bean.getPhoto()));
		} else {
			return new DefaultStreamedContent(FacesContext
					.getCurrentInstance().getExternalContext()
					.getResourceAsStream("/static/img/default-image.png"));
		}
	}
}
 
开发者ID:machadolucas,项目名称:watchout,代码行数:17,代码来源:PlacesBean.java

示例10: getOutputFile

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getOutputFile(int saveFormat) {
    if (!isLoaded()) {
        return null;
    }

    byte[] buf;
    String ext = getExtensionForSaveFormat(saveFormat);

    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        getAsposeWorkbook().save(out, saveFormat);
        buf = out.toByteArray();
    } catch (Exception x) {
        LOGGER.throwing(null, null, x);
        msg.sendMessageDialog("Could not export", x.getMessage());
        return null;
    }

    return new DefaultStreamedContent(new ByteArrayInputStream(buf), "application/octet-stream", "Spreadsheet." + ext);
}
 
开发者ID:AsposeShowcase,项目名称:Html5_Spreadsheet_Editor_by_Aspose.Cells_for_Java,代码行数:21,代码来源:WorkbookService.java

示例11: getFile

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getFile() {

		ILCDZip zip;
		try {
			zip = export( this.stock );

			if ( zip != null ) {
				FileInputStream stream = new FileInputStream( zip );
				file = new DefaultStreamedContent( stream, "application/zip", getZipFileName() );
			}
		}
		catch ( IOException e ) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return file;
	}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:19,代码来源:DataExportController.java

示例12: getImage

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public StreamedContent getImage() {

        //todo maybe need to load from db

        if (user.getUserProfile().getPicture() != null) {
            return new DefaultStreamedContent(new ByteArrayInputStream(user.getUserProfile().getPicture()));
        }
        return null;
    }
 
开发者ID:chr-krenn,项目名称:chr-krenn-fhj-ws2017-sd17-pse,代码行数:10,代码来源:UserDataBean.java

示例13: SessionScopeBean

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public SessionScopeBean() {
	auth = new AuthenticationVO();
	imageStore = new MaxSizeHashMap<Object, StreamedContent>(WebUtil.IMAGE_STORE_MAX_SIZE);
	// selectionSetServiceCache = new HashMap<Class, HashMap<Object, Object>>();
	logon = null;
	failedAttempts = 0;
	authenticationFailed = false;
	localPasswordRequired = false;
	authenticationFailedMessage = null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:11,代码来源:SessionScopeBean.java

示例14: getImage

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public synchronized StreamedContent getImage() {
	FacesContext context = FacesContext.getCurrentInstance();
	if (PhaseId.RENDER_RESPONSE.equals(context.getCurrentPhaseId())) {
		// So, we're rendering the view. Return a stub StreamedContent so that it will generate right URL.
		return new DefaultStreamedContent();
	}
	else {
		// So, browser is requesting the image. Return a real StreamedContent with the image bytes.
		String uuid = WebUtil.getParamValue(GetParamNames.UUID);
		if (imageStore.containsKey(uuid)) {
			return imageStore.get(uuid);
		}
		return new DefaultStreamedContent();
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:16,代码来源:SessionScopeBean.java

示例15: putImage

import org.primefaces.model.StreamedContent; //导入依赖的package包/类
public synchronized StreamedContent putImage(Object key, byte[] image, String mimeType) {
	if (image != null && image.length > 0 && mimeType != null && mimeType.length() > 0) {
		return imageStore.put(key, new DefaultStreamedContent(new ByteArrayInputStream(image), mimeType));
	} else {
		return imageStore.remove(key);
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:SessionScopeBean.java


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