I'm trying to use byte array (as BLOB saved in DB) to return the StreamedContent to the p:graphicImage, that is inside a p:datagrid, as follows:
<p:dataGrid id="dtResults" rows="10" columns="3"
value="#{searchResultsController.items}" var="item">
<p:column>
<p:panel header="#{item.displayName}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage binding="#{imagestickiesController.imageforuserid}"
width="100" height="100" value="#{imagestickiesController.image}">
<f:attribute name="uID" value="#{item.userID}" />
</p:graphicImage>
<h:outputText id="lAboutMe" value="#{item.aboutMe}"/>
</h:panelGrid>
</p:panel>
</p:column>
</p:dataGrid>
This one returns blank images. Is someone have an idea why?
ADDED: The part of the ImagestickiesController in this context is:
public class ImagestickiesController {
private GraphicImage imageforuserid;
public GraphicImage getImageforuserid(){
return imageforuserid;
}
public void setImageforuserid(GraphicImage gi){
imageforuserid = gi;
}
public StreamedContent getImage(){
System.out.println("In getImage");
System.out.println(imageforuserid);
System.out.println(imageforuserid.getAttributes().get("uID"));
Long value = (Long)imageforuserid.getAttributes().get("uID");
if (value!=null)
{
Imagestickies curr = ejbFacade.FindByUserID(value);
if (curr!=null)
{
System.out.println(curr);
InputStream is = new ByteArrayInputStream(curr.getStickies().getContent());
StreamedContent res = new DefaultStreamedContent(is);
return res;
}
}
return null;
}
}
The ejbFacade makes the query to the DB. I've printed the size of the resulted imaged in bytes, and saw it was OK, but still the image is not shown... Another thing is that the item (User entity) cannot reach the image within the DB due to restrictions in the design.
Thanks...