2 Replies Latest reply on Sep 4, 2008 12:00 PM by sambolino

    rich:uploadFile + a4j:mediaOutput  - can't get it working

    sambolino

      greetings!

      could anyone possibly detect what am i doing wrong here? i'm trying to keep it simple here - during creation/editing of an employee entity upload a jpg and show it

      <a4j:mediaOutput id="mediaout" element="img" mimeType="image/jpeg"
       createContent="#{employeeService.paint}" session="true"
       value="#{employeeService.employee.picture}"
       style="width:100px; height:100px;" cacheable="false" />
       <rich:fileUpload fileUploadListener="#{employeeService.listener}"
       id="upload" immediateUpload="true" acceptedTypes="jpg"
       listHeight="60px" autoclear="true">
       <a4j:support event="onuploadcomplete" reRender="mediaout" />
       </rich:fileUpload>



      methods inside conversational bean:

      public void listener(UploadEvent event) throws IOException {
       File file = event.getUploadItem().getFile();
       InputStream in = new FileInputStream(file);
       byte[] data = new byte[in.available()];
       in.read(data);
       employee.setPicture(data);
       }
      
       public void paint(OutputStream out, Object obj) throws IOException {
       out.write(employee.getPicture());
       // same with out.write( (byte[]) obj);
       }


      employee.picture is byte[] of course, and it gets persisted later into database. so i guess something's wrong with my treatment of mediaOutput