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

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

    Veljko Vujcic Newbie


      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"
       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" />

      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()];
       public void paint(OutputStream out, Object obj) throws IOException {
       // 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