5 Replies Latest reply on Apr 3, 2012 4:37 AM by Andrew Wheeler

    Seam 3 s:graphicImage tag

    fortega Newbie

      Is there a replacement for the s:graphicImage tag in seam 3?
      What about all the other useful s:... tags?

        • 1. Re: Seam 3 s:graphicImage tag
          Jason Porter Master

          Not as of yet, sorry. I believe they're on the list, check JIRA, if they're not there, please add tickets.

          • 2. Re: Seam 3 s:graphicImage tag
            Andrew Wheeler Newbie

            You could try mediaOutput from Richfaces. Only problem is you'll have to scale the images yourself (look at the Seam 2 code for how it was done).

            Question for the Seam team: I thought Seam 3 was going to avoid ui components and leave that to Richfaces. Is this still the plan? It would make a better seperation of concerns. Does the Seam team talk to the Richfaces team?

            • 3. Re: Seam 3 s:graphicImage tag
              brin jack Newbie

              Does richfaces4  have mediaOutput tag or is it a4j:mediaOutput .

              • 4. Re: Seam 3 s:graphicImage tag
                hantsy bai Master

                I tried to use a4j:mediaOutput to produce image binary...I dislike it.


                1.  I must write the produce method myself

                2. a4j:mediaOutput encoded the binary data as string and put it in the url, then decoded it and display it in the browser, It can not process big data(due to the browser url length limit).

                3. I used in Conversation scoped pages...it does not work, the generated url does not append conversation id as parameter.


                I used a very stupid way to overcome this problem now, I upload my images in /resouces/xxxx redirectly(in before version, I stored the image in database ), and use h:graphicImage and jsf2 library attribute to display it directly.


                I browsed the Seam 2 graphicImage component, it used HTTP session to store the image binary data, then display it using a servlet(is this right?)...I think it is bad performance.

                • 5. Re: Seam 3 s:graphicImage tag
                  Andrew Wheeler Newbie

                  I wrote a generic producer class that had a map of images  caching them in the Request or View Scope. This bean was called from a4j:mediaOutput to write the content.



                  <a4j:mediaOutput element="img" createContent="#{imageCache.createContent}" value="#{img.identifier}" cacheable="false" id="image" mimeType="#{p.mimeType}"/>


                  I then injected this into my ImageGallery bean which retrieved the data from the JCR (or equally database), generated the identifier and pushed it to the ImageCache bean.


                  I also experimented with a generic ResourceHandler that fired events with a payload to match resource requests on library name or just resource name . The receiver of the event could custom load the resource from JCR/database before it was passed on.


                  E.g. You could define an image in a non-existant resource location such as:


                  <h:graphicImage library="db" name="1234"/>


                  and load the resource from the database using the name identifier and return it as a real resource.


                  It could also intercept resources after they were loaded from the standard location (think /resources/images/logo.png) and alter the content (think scaling or watermarking).


                  This was all just proof-of-concept and would need more than a part-time java hack like me have a good look at it.