0 Replies Latest reply on Aug 24, 2011 3:41 AM by Özkan Canbay

    rich:fileUpload and rich:progressBar

    Özkan Canbay Newbie



      I am using Richfaces 4.0.0.Final under Tomcat 7.0.


      Here is the xhtml-part


      <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
          acceptedTypes="csv, zip"
          <a4j:ajax event="uploadcomplete" execute="@none" render="info" />
          <a4j:ajax event="filesubmit" execute="@form" render="info" />
          <f:facet name="progress">
                  label="#{fileUploadBean.processed} of #{fileUploadBean.toProcess} processed.">



      and here the fileUploadBean



      import java.io.Serializable;
      import javax.inject.Inject;
      import javax.inject.Named;
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.richfaces.event.FileUploadEvent;
      import org.richfaces.model.UploadedFile;
      import org.springframework.context.annotation.Scope;
      import de.mbb.abgst.service.Loader;
      @Scope(value = "session")
      public class FileUploadBean implements Serializable {
          private final static Log log = LogFactory.getLog(FileUploadBean.class);
          private static final long serialVersionUID = -4473074092916884407L;
          private Loader loader;
          private int lineCount = 0;
          public FileUploadBean() {
          public void listener(FileUploadEvent event) throws Exception {
              UploadedFile item = event.getUploadedFile();
              lineCount = loader.countLine(item.getInputStream());
              log.info("Start loading ...");
          public int getProcessed() {
              int processed = loader.getProcessed();
              log.info("processed: " + processed);
              return processed;
          public int getToProcess() {
              return lineCount;
          public int getCurrentValue() {
              int ret = 0;
              if (lineCount > 0) {
                  ret = getProcessed()*100/lineCount;
              return ret;



      Most of the time is spend on




      Uploading takes just a couple of seconds, but the progressbar is filled after

      uploading is processed.

      I thought, I could overwrite the progressbar with own configuration, but the shown code has no effect.


      Trying to put a separate progressbar would be also fine, but

      <a4j:ajax event="filesubmit" execute="@form" render="info" />

      is not firing (although an explicit onfilesubmit is firing) so that I can't enable the separate progressbar.


      Any idea or best practice ?


      Thanks and regards