s:grahicImage in datatable bug?
alartin Jul 5, 2010 4:06 AMHi all,
I have a Person entity with a photo attribute with byte[] type and use seam-gen to generate ui (it uses seam application framework, entityhome and entityquery). In the personList.xhtml, I use s:graphicImage to show all the person's photos.
<rich:dataTable id="personList"
var="_person"
value="#{personList.resultList}"
rendered="#{not empty personList.resultList}">
<h:column>
<f:facet name="header">
<ui:include src="layout/sort.xhtml">
<ui:param name="entityList" value="#{personList}"/>
<ui:param name="propertyLabel" value="Id"/>
<ui:param name="propertyPath" value="person.id"/>
</ui:include>
</f:facet>
<h:outputText value="#{_person.id}"/>
</h:column>
<h:column>
<f:facet name="header">Photo</f:facet>
<s:graphicImage rendered = "#{_person.photo.size != null}"
value = "#{_person.photo.data}">
<s:transformImageSize width="80" maintainRatio="true"/>
</s:graphicImage>
<h:outputText value="Not Available" rendered = "#{_person.photo.size == null}"/>
</h:column>The strange thing appears when I edit/upload a photo for a person. For example, I upload a image for person whose id is 3. When I visit personList.xhtml, I find the photo column of persons with id '1' and '2' show Not Available
which I expect. But the photo column ofpersons with id larger than 3 show the same image I upload for person whose id is 3!!! And follows the Not Available
Text!!
I am sure the photo of the persons whose id is larger than 3 is empty or null after I checked the database. And I also print their size in the page and shows zero that I expect. I do think this is due to the seam cause I checked the page source and found
seam/resource/graphicImage/org.jboss.seam.ui.GraphicImageStore.7cda72f7-129a1695b7a--7f69.png seam/resource/graphicImage/org.jboss.seam.ui.GraphicImageStore.7cda72f7-129a1695b7a--7f68.png seam/resource/graphicImage/org.jboss.seam.ui.GraphicImageStore.7cda72f7-129a1695b7a--7f67.png seam/resource/graphicImage/org.jboss.seam.ui.GraphicImageStore.7cda72f7-129a1695b7a--7f66.png ...
But I just upload one photo for a person with id is 3!! There must be something wrong with the imagestore. Can somebody help?
Or can somebody show a demo about how to show images in a datatable?
Thanks in advance.