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


Java DefaultStreamedContent类代码示例

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


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

示例1: downloadFile

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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.DefaultStreamedContent; //导入依赖的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.DefaultStreamedContent; //导入依赖的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.DefaultStreamedContent; //导入依赖的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: getStreamedPhoto

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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

示例6: getStreamedInsuranceIcon

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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

示例7: getStreamedIcon

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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

示例8: getStreamedPhoto

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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

示例9: getOutputFile

import org.primefaces.model.DefaultStreamedContent; //导入依赖的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

示例10: exportXML

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void exportXML() {
	if (this.bean == null || this.bean.getIdentificator() == null
			|| this.bean.getIdentificator().equals("")) {
		MessageUtils.showWarnInForm(bundle.getString("warning_title"),
				bundle.getString("export_selection_required_message"));
	} else {
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		try {
			JAXBContext jaxbContext = JAXBContext.newInstance(Post.class);
			Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
			jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
					true);
			jaxbMarshaller.marshal(bean, output);
		} catch (Exception e) {

		}
		ByteArrayInputStream input = new ByteArrayInputStream(
				output.toByteArray());
		exportedXML = new DefaultStreamedContent(input, "application/xml",
				bean.getIdentificator() + ".xml");
	}
}
 
开发者ID:machadolucas,项目名称:avanto,代码行数:23,代码来源:PostsBean.java

示例11: linechartBase64Str

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void linechartBase64Str(){
	 InputStream stream2 = servletContext.getResourceAsStream("/images/line.png");
	 file = new DefaultStreamedContent(stream2, "image/png", "LineChart.png");
	
    if(base64Str.split(",").length > 1){
        String encoded = base64Str.split(",")[1];
        byte[] decoded = Base64.decodeBase64(encoded);
        // Write to a .png file
        try {
            RenderedImage renderedImage = ImageIO.read(new ByteArrayInputStream(decoded));
            ImageIO.write(renderedImage, "png", new File(servletContext.getRealPath("images/line.png"))); 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:17,代码来源:InvestmentSummaryController.java

示例12: piechartUSBase64Str

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void piechartUSBase64Str(){
	 
	 InputStream stream1 = servletContext.getResourceAsStream("/images/pie1.png");
	 file1 = new DefaultStreamedContent(stream1, "image/png", "US_Piechart.png");
    if(base64Str1.split(",").length > 1){
        String encoded = base64Str1.split(",")[1];
        byte[] decoded = Base64.decodeBase64(encoded);
        // Write to a .png file
        try {
            RenderedImage renderedImage = ImageIO.read(new ByteArrayInputStream(decoded));
            ImageIO.write(renderedImage, "png", new File(servletContext.getRealPath("images/pie1.png"))); 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
   
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:18,代码来源:AccountSummaryController.java

示例13: piechartUKBase64Str

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void piechartUKBase64Str(){
	 InputStream stream2 = servletContext.getResourceAsStream("/images/pie2.png");
	 file2 = new DefaultStreamedContent(stream2, "image/png", "Uk_Piechart.png");
	
    if(base64Str2.split(",").length > 1){
        String encoded = base64Str2.split(",")[1];
        byte[] decoded = Base64.decodeBase64(encoded);
        // Write to a .png file
        try {
            RenderedImage renderedImage = ImageIO.read(new ByteArrayInputStream(decoded));
            ImageIO.write(renderedImage, "png", new File(servletContext.getRealPath("images/pie2.png"))); 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:17,代码来源:AccountSummaryController.java

示例14: barchartBase64Str

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void barchartBase64Str(){
	 InputStream stream2 = servletContext.getResourceAsStream("/images/bar.png");
	 file3 = new DefaultStreamedContent(stream2, "image/png", "BarChart.png");
	
    if(base64Str3.split(",").length > 1){
        String encoded = base64Str3.split(",")[1];
        byte[] decoded = Base64.decodeBase64(encoded);
        // Write to a .png file
        try {
            RenderedImage renderedImage = ImageIO.read(new ByteArrayInputStream(decoded));
            ImageIO.write(renderedImage, "png", new File(servletContext.getRealPath("images/bar.png"))); 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:17,代码来源:AccountSummaryController.java

示例15: donutchartBase64Str

import org.primefaces.model.DefaultStreamedContent; //导入依赖的package包/类
public void donutchartBase64Str(){
	 InputStream stream = servletContext.getResourceAsStream("/images/donut.png");
	 file = new DefaultStreamedContent(stream, "image/png", "DonutChart.png");
	
    if(base64Str.split(",").length > 1){
        String encoded = base64Str.split(",")[1];
        byte[] decoded = Base64.decodeBase64(encoded);
        // Write to a .png file
        try {
            RenderedImage renderedImage = ImageIO.read(new ByteArrayInputStream(decoded));
            ImageIO.write(renderedImage, "png", new File(servletContext.getRealPath("images/donut.png"))); 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:17,代码来源:TransactionSummaryController.java


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