3 Replies Latest reply on Oct 21, 2011 3:41 AM by lucaster

    rich:fileUpload does not fire 'uploadcomplete' event

    manakor

      I am on JSF 2 using Richfaces 4.

      I have located <rich:fileUpload> on my page like this:

      <rich:fileUpload 
          fileUploadListener="#{actionsContainer.fileStorageActions.uploadListener}"
          id="uploader"
      
          immediateUpload="true"
          acceptedTypes="avi, flv, mp4, ogv, mp3, wav"
          maxFilesQuantity="1" 
          noDuplicate="true"
          autoclear="true"
          onerror="alert('Error in uploader');"
          
          onuploadcomplete="alert('Uploaded');"
      ></rich:fileUpload>
      

      And so, when I open a page I have uploader ready. I am clicking on 'Select files' button, select a file I wish to upload and hot Enter key.

      1. immediateUpload attribute with a value 'true' is not taken in mind, and upload is not starting automaticaly after I selected a file;
      2. maxFilesQuantity attribute is not taken in mind and I am able to add more files by selecting another time;

       

      Than I click 'Upload' button and uploading starts (I'm in debug mode looking what does my action do) and file is successfully uploaded to a folder (no errors on BackEnd side), however no onuploadcomplete, no onerror events has been fired. Also autoclean attribute with a value 'true' hasn't made it's job.

       

      Than I've changed onuploadcomplete attribute into onfileuploadcomplete as it was in Richfaces3 and JSF1. And still it doesn't fire. Than I decided to try to use <a4j:ajax> tag to fire an event:

      <a4j:ajax event="uploadcomplete" oncomplete="alert('Uploaded');" render="myPanel" />
      

      And still no event has been fired, and 'myPanel', which exists in the page as <a4j:outputPanel> hasn't been rendered.

       

      Besides this, when I am checking JS errors on Firebug console, there're no errors at all.

       

      Does anyone faced the same problems?

      If the component has been completely migrated from Richfaces3 to 4?

        • 1. Re: rich:fileUpload does not fire 'uploadcomplete' event
          manakor

          After trying different ways to reach 'onuploadcomplete' event, I decided to look into JBOSS Issue Tracking System and found an opened ticket RF-10978 which gave me a clue on the problem I've described above.

           

          Here's a quote by issue ticket creator:

          Including the Primefaces 2 library along with Richfaces 4.0 Final causes the Richfaces fileUpload component to break.  In the JBoss logs  this message appears when rendering the page with the component:

           

          "JSF1091: No mime type could be found for file fileUploadProgress. To resolve this, add a mime-type mapping to the applications web.xml"

           

          Also when monitoring the HTTP traffic in Fiddler I see this entry over and over. Appears to be stuck in some loop

          /lsweb/rfRes/fileUploadProgress.jsf?ln=org.richfaces&rf_fu_uid_alt=0.712090154203886

           

          And so, I decided to get rid of primefaces by removing it's dependency inside project pom.xml file:

          <!--

          <dependency>

              <groupId>org.primefaces</groupId>

              <artifactId>primefaces</artifactId>

              <version>2.2.1</version>

          </dependency>

          -->

           

          Finally, 'oncomplete' event has been fired properly, after file has been uploaded via <rich:fileUpload> component.

          However, as I see the issue ticket has opened status, this means it's not solved yet and I hope will be when I really need to use Primefaces.

          • 2. Re: rich:fileUpload does not fire 'uploadcomplete' event
            jnt30

            I've added in a sample Maven application as well to this issue.

            • 3. Re: rich:fileUpload does not fire 'uploadcomplete' event
              lucaster

              I'm having the exact same issue.

               

              And on top of that, the  "maxFilesQuantity" attribute doesn't exist anymore in RichFaces 4....

               

              There is no way to limit the number of uploaded files!!!

               

              <rant>

              Why does it always happen that new versions (boldly called "Final"!!) of big frameworks/libraries lack some basic/important functionalities that were present in the old version?

              The "Require no more, promise no less" is long time dead, and spinning in its grave.

              No wonder more and more developers turn to other languages and frameworks.

              </rant>

               

               

              Edit: updrading to 4.1.0-SNAPSHOT fixed the issue.