I need to display an image using p:graphic I'm not using a p:dataTable
jsf Page
<p:graphicImage value="#{indexController.image}">
<f:param name="id" value="#{indexController.imagem.id}" />
</p:graphicImage>
my @Controller
public StreamedContent getImage() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
}
else {
String id = context.getExternalContext().getRequestParameterMap().get("id");
imagem = imagemService.findById(Long.valueOf(1));
StreamedContent sc = new DefaultStreamedContent(new ByteArrayInputStream(imagem.getArquivo()));
return sc;
}
}