1 Reply Latest reply on Oct 7, 2008 3:29 PM by Daniel Roth

    h:graphicImage instead of s:graphicImage

    nimo stephan Master

      I use


      <s:graphicImage value="../img/myImage.gif" />



      and get the failure:


      Image pointed to must exist (input stream must not be null)



      I am sure, that this path is valid. I tried it with this:



      <h:graphicImage value="../img/myImage.gif" />




      and h:graphicImage works, but s:graphicImage does not work.



      Why ??


        • 1. Re: h:graphicImage instead of s:graphicImage
          Daniel Roth Apprentice

          h:graphicImage points to a path relative to the web server.


          s:graphicImage looks for a file on the disk, so that it can be read and transformed. Do something like (this is just written, not checked at all):


          <s:graphicImage value="#{myBean.image}"/>
          



          and


          @Name("myBean")
          public class MyBean {
          
            public InputStream getImage() {
               getClass().getResourceAsStream("/img/bla.jpg");
            }
           
          }
          



          Depending on what AS you use you might get away with


          <s:graphicImage value="/path/to/file.jpg"/>
          




          s:graphicImage will then use the given path to get the stream with something like ResourceLoader.instance().getResourceAsStream(/path/to/file.jpg);