3 Replies Latest reply on Feb 8, 2008 6:03 PM by dhinojosa

    s:graphicImage problem

    seammm

      Hi - I am having difficult time for seemingly trivial task that is uploading a picture into a byte[] and displaying it. Uploading does not give any error but s:graphicImage does not show anything although productHome.instance.picture ne null IS satisfied. Any idea is appreciated. Thanks.


      THIS IS THE UPLOAD FORM (productHome IS managed at this point and uploads just fine, I checked the blob field in mysql, it is not null) -----------------

      <h:form id="uploadForm" enctype="multipart/form-data">

      <rich:panel>
      <f:facet name="header">Upload picture for #{productHome.instance.name}</f:facet>

      <s:decorate id="fileDecoration" template="layout/edit.xhtml">
      <ui:define name="label">
      <s:graphicImage rendered="#{productHome.instance.picture ne null}"
      value="#{productHome.instance.picture}"/>
      </ui:define>
      <s:fileUpload id="file"
      data="#{productHome.instance.picture}"
      contentType="#{productHome.instance.pictureContentType}"/>
      </s:decorate>



      </rich:panel>


      <h:commandButton id="save"
      value="Upload"
      action="#{productHome.upload}" />
      <h:commandButton id="done"
      value="Done"
      view="/product.xhtml" />


      </h:form>


      THIS ARE THE FIELDS IN PRODUCT (getter for picture is marked @Lob) ----------------------

      private byte[] picture;
      private String pictureContentType;



      THIS IS THE UPLOAD METHOD (IT GOES BACK TO UPLOAD FORM) --------------

      public String upload()
      {
      log.info("----UPLOAD CALLED " + getInstance().getPicture().length);

      return null; //"/product.xhtml";
      }

        • 1. Re: s:graphicImage problem
          dhinojosa

          Did you install the seam resource servlet in your web.xml

          • 2. Re: s:graphicImage problem
            seammm

            I did but I am not getting the bytes thru a servlet as in seamspace example. I am accessing the byte[] via the back bean's property getter. According to seam doc getting picture data directly from byte[] should be possible. Thanks.

            value — image to display. Can be a path String (loaded from the classpath), a byte[], a java.io.File, a java.io.InputStream or a java.net.URL. Currently supported image formats are image/png, image/jpeg and image/gif.



            <servlet-name>Seam Resource Servlet</servlet-name>
            <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>


            <servlet-mapping>
            <servlet-name>Seam Resource Servlet</servlet-name>
            <url-pattern>/seam/resource/*</url-pattern>
            </servlet-mapping>

            • 3. Re: s:graphicImage problem
              dhinojosa

              Did you go to the debug page and see if that image was still there? I could be a scoping issue.