2 Replies Latest reply on Jul 5, 2010 4:31 AM by alartin

    s:grahicImage in datatable bug?

    alartin

      Hi 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.



        • 1. Re: s:grahicImage in datatable bug?
          alartin

          Sorry I forgot my seam is 2.2.0.GA and used JBoss AS 5.1

          • 2. Re: s:grahicImage in datatable bug?
            alartin

            Sorry, this is not a bug of Seam.
            It turns out if rendered condition does not match, it will render the previous entity in the list. I do not know why.
            In this case, my size attribute is primitive type and should be compared with zero rather than null, and the image still point to the previous person's image but all other attributes displayed right. So, this kind of behavior confuse me.