Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p:column headerText="Foto" style="text-align: center; width: 100px">
- <p:graphicImage value="#{pesquisaNoticiasBean.foto}"
- cache="disable">
- <f:param name="nomeFoto" value="#{noticia.foto_noticia}" />
- </p:graphicImage>
- </p:column>
- public StreamedContent getFoto() throws IOException {
- String caminho = "C:/workspace Web/Projetos Profissionais/Fotos para teste/";//Aqui você coloca o caminho do diretório onde as imagens estão sendo armazenadas no servidor
- FacesContext context = FacesContext.getCurrentInstance();
- String nomeFoto = context.getExternalContext().getRequestParameterMap().get("nomeFoto");
- File foto = new File(caminho+nomeFoto);
- DefaultStreamedContent content = null;
- try {
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(foto));
- byte[] bytes = new byte[in.available()];
- in.read(bytes);
- in.close();
- content = new DefaultStreamedContent(new ByteArrayInputStream(bytes), "image/jpeg");
- } catch (Exception e) {
- e.getStackTrace();
- }
- return content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement