after googling the whole day and almost going crazy, I just gave up and now trying to find out if someone can help me out with this issue.
Well, I'm trying to show an image inside p:dataTable with p:graphicImage, but the image looks like "broken" as you can see in the pic below:
I googled A LOT and found many people, including BaluscC saying the same thing: Getting the image as StreamedContent Object, but with me it doesn't work and the weird thing is that there's no error showing on my console. Here's my code:
On my bean "Place" getting the blob image (byte[]) and transforming to StreamedContent
public StreamedContent getImageStreamContent() {
if(image != null){
InputStream is = new ByteArrayInputStream(image);
imageStreamContent = new DefaultStreamedContent (is, "image/png");
return imageStreamContent;
}else{
return null;
}
}
Here's my dependencies on maven:
<!-- Regarding to upload image -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
Here's my web.xml
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
And here's my datatable:
<p:column headerText="Photo" width="80">
<p:graphicImage value="#{place.imageStreamContent}" />
</p:column>
Anyone would know what I'm doing wrong?
Cheers!