4 Replies Latest reply on Dec 16, 2009 4:11 AM by Jörn Ziemke

    rich:fileUpload> individual/ dynamic error messages per file

    Leander Zeischka Newbie


      My scenario:
      I have a portlet for uploading files and forwarding their contents on to web services via byte[].
      Therefore, I have a listener methode registered for fileUpload:

       public void listener( UploadEvent event ) throws Exception
       UploadItem item = event.getUploadItem();
       File file = new File();
       file.setName( item.getFileName() );
       file.setData( item.getData() );
       submitFile( file );

      The submitFile method calls the web services.
      Each file results in one call and may cause an individual error.

      My goal:
      If an error occurs during web service call, then the error message should be written in file list to the concerned file!
      I registered an attribute of a backing bean for error messages:
      <rich:fileUpload ... transferErrorLabel="#{fileUpload.errorText}" ...

      This attribute is filled with the individual error messages.

      My problem:
      The updated server side backing bean attribute containing the error message is never read, since the file upload component in client is not rerendered!
      If I rerender it, all contained files in file list get lost!

      My questions:
      1. Is there a possibility to hold state of client file list in server backing bean? (Seems difficult, since "onadd" does not provide information about chosen file!)
      ... so that I am always able to recreate file list in fileupload component on "rerender".
      2. Is there a workaround for my problem with the dynamic error messages?