3 Replies Latest reply on Oct 12, 2012 10:47 AM by Sergey Morenets

    How to use a4j:mediaOutput correctly for displaying images?

    Tomas Zeman Newbie

      Using the code below I can't get the image in the web page. I'm not sure if I understand the documentation in the right way and I'm not able to find any problem with this code.




      @ManagedBean(name = "imageBean")
          public class ImageBean {
                    public void paint(OutputStream os, Object data) throws IOException {
                              BinaryContent content = (BinaryContent) data;
                              BufferedImage image = ImageIO.read(new ByteArrayInputStream(content.getContent()));
                              ImageIO.write(image, "jpg", os);



          <rich:dataTable value="#{dataProviderBean.aoRequests}" var="item">
                          <f:facet name="noData">No messages are available.</f:facet>
                                    <f:facet name="header">Image data</f:facet>
                                    <rich:list value="#{item.imageContents}" var="content">
                                              <a4j:mediaOutput element="img" cacheable="false" session="false"
                                                        createContent="#{imageBean.paint}" value="#{content}" />