2 Replies Latest reply on Dec 8, 2011 11:29 AM by maze_fr

    Fileupload - How to trigger automatic upload and progress bar

    echofloripa

      I am implementing a one button only file upload functionality, and using richfaces 4.0 to do this.

       

      In richfaces 3.3 there was a property called immediateUpload, which would start the upload straight after the file selection.

      This option doesn't exist on 4.x, so I thought in hack around to make this happen.

       

      I was planning in using the event called onadd, immediateUpload, to call the internal method __submit, but I now realised that this even was removed from 4.x, and now the only remaining events are onfilesubmit and onuploadcomplete.

       

      How could I achieve this on richfaces 4.0????

        • 1. Re: Fileupload - How to trigger automatic upload and progress bar
          echofloripa

          Ok, I did this myself.

          We copied the rich:upload component from richfaces, and encapsulated into our own component.

           

          I then changed the javascript file as follows:

           

            startUploading: function() {

                      this.state.css("display", "block");

                      this.addButton.style.display = 'none';

                      this.feedback.style.display = '';

                      this.link.html("");

                      this.input.attr("name", this.fileUpload.id);

                      this.model.state = ITEM_STATE.UPLOADING;

                     this.feedback=document.getElementById("feedback");

                      this.feedback.html(ITEM_STATE.UPLOADING);

                      this.uid = Math.random();

                      this.fileUpload.__submit();

                      if (this.fileUpload.progressBar) {

                         this.fileUpload.progressBar.setValue(0);

                          this.feedback.html(this.fileUpload.progressBarElement.detach());

           

                          var params = {};

                          params[UID_ALT] = this.uid;

                          this.fileUpload.progressBar.enable(params);

                      }

                  },

           

          But I need the progress bar to appear on the same place of the button, or at the right side.

          • 2. Re: Fileupload - How to trigger automatic upload and progress bar
            maze_fr