1 Reply Latest reply on Apr 18, 2012 9:20 PM by peter.falken

    SOLVED: a4j:mediaOutput - Error with Images larger than 2Kb

    peter.falken

       

      On a default JBoss 7.1.1 the following code won't display Images larger than 2Kb.

      It seems that Request is too big and the server does not see the HTTP/1.1

      I get a HEADER Response

      1. Request Method:GET
      2. Status Code:505 HTTP Version Not Supported

       

      I'm using the code from the RichFaces Showcase

       

      http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=fileUpload&skin=blueSky

       

       

      <rich:dataTable value="#{tBean.files}" var="ff">

        <rich:column>

        <f:facet name="header">

                         Image

                      </f:facet>

        <a4j:mediaOutput element="img" mimeType="#{ff.contentType}"

        style="width:100px; height:100px;" createContent="#{tBean.paint}"

                                                        value="#{ff}" />

        </rich:column>

        </rich:dataTable>

       

      ===========================================================

       

                public void paint(OutputStream stream, Object object) throws IOException {

                          if(object instanceof TFile){

                                    TFile ff = (TFile) object;

                                    System.out.println("Writting: "+ ff.getFsName() + " Bytes: "+ ff.getSize());

                                    stream.write(ff.getData(),0, ff.getSize().intValue());

                          }

                          stream.close();

                }


        • 1. Re: a4j:mediaOutput - Error with Images larger than 2Kb
          peter.falken

          Since <a4j:mediaOutput> Stores its data in a URI - it's not recommended to pass the Value of the Data to be drawn in the XHTML.

          It is better to just pass an ID and fetch the Raw Data to be output the Paint Method.

          Still I'm left with doubt as to how does the RichFaces ShowCase works with an 8Kb PNG Image and it doesn't work with my Development Environment.

           

          a4j:mediaOutput and large objects as value

           

          https://community.jboss.org/wiki/A4jmediaOutputAndLargeObjectsAsValue

           

          How to use a4j:mediaOutput correctly for displaying images?

           

          http://stackoverflow.com/questions/7677207/how-to-use-a4jmediaoutput-correctly-for-displaying-images

           

           

          The correct code should look like this:

           

          <a4j:mediaOutput element="img" createContent="#{tBean.paint}" cacheable="false"

            mimeType="#{ff.contentType}" style="width:100px; height:100px;"

            value="#{ff.id}" />

           

          ===================================

           

                    public void paint(OutputStream stream, Object object) throws IOException {

                              if(object instanceof Long){

                                        TFile ff = dm.getTFile((Long) object);

                                        System.out.println("Writting: "+ ff.getFsName() + " Bytes: "+ ff.getSize());

                                        stream.write(ff.getData(),0, ff.getSize().intValue());

                              }

                              stream.close();

                    }