9 Replies Latest reply on Sep 22, 2009 5:36 PM by Greg Noe

    Three rich:fileUpload issues.

    Greg Noe Newbie

      Hi All,

      I'm having a couple issues with the rich:fileUpload component.

      Problem #1: When using the flash module for multi-file uploads, the Add button is disable upon the first page load. The page must be reloaded for the Add button to be enabled. I can reproduce this in IE7 and FF3.0.11. I have tried the following to get it to work:

      - Set the value of the "maxFilesQuantity" attribute using a bean field, and by hard coding an integer value.
      - Set the "disabled" attribute to false using a field in my file upload bean, and by hard coding "false".

      Problem #2: When trying to do multiple file uploads with the flash module in an HTTPS session using Firefox 3.0.11 the rich:fileUpload component shows Transfer error occurred and quits uploading. I don't see any errors in Firebug or in my web server console. I've also watched the session through Fiddler and don't see any errors there either. The non-flash uploader doesn't have this problem and IE 7 doesn't have this problem with the normal or the flash module.

      Any ideas?

      My environment:

      RichFaces Version: 3.3.1 GA
      Web Server: Tomcat 6.0.18

      The HTML:

       allowFlash="#{photoToPDFBean.useFlash}" --- Always "true"
       disabled="#{photoToPDFBean.controlDisabled}" --- Always "false"
       maxFilesQuantity="#{photoToPDFBean.uploadsAvailable}" --- Defaults to "20"
       uploadData="#{photoToPDFBean.uploadData}" --- List of UploadItem
       acceptedTypes="jpg, gif, png, bmp">
       <a4j:support event="onuploadcomplete" reRender="info" />

      The (important) Java stuff:
      import java.util.ArrayList;
      import java.util.List;
      import javax.faces.context.FacesContext;
      import javax.servlet.http.HttpServletResponse;
      import org.apache.commons.io.FileUtils;
      import org.apache.commons.io.FilenameUtils;
      import org.apache.commons.lang.StringUtils;
      import org.richfaces.event.UploadEvent;
      import org.richfaces.model.UploadItem;
      import com.company.java.web.report.util.pdf.PageNumbersWatermark;
      import com.company.java.web.utils.CompanyDateUtil;
      import com.company.java.web.utils.JsfUtils;
      import com.company.java.web.utils.upload.ImageUploadFile;
      public class PhotoToPDFBean {
       private boolean controlDisabled = false;
       private boolean useFlash = true;
       private List<ImageUploadFile> files;
       private int uploadsAvailable = 20;
       private List<UploadItem> uploadData;
       * Constructor for PhotoToPDFBean
       public PhotoToPDFBean() {
       // Auto-generated constructor stub
       * Getter for the files.
       * @return the List<ImageUploadFile> : files
       public final List<ImageUploadFile> getFiles() {
       if (null == this.files) {
       this.files = new ArrayList<ImageUploadFile>();
       return this.files;
       * Setter for the files.
       * @param files the files to set
       public final void setFiles(List<ImageUploadFile> files) {
       this.files = files;
       * Getter for the uploadsAvailable.
       * @return the int : uploadsAvailable
       public final int getUploadsAvailable() {
       return this.uploadsAvailable;
       * Setter for the uploadsAvailable.
       * @param uploadsAvailable
       public final void setUploadsAvailable(int uploadsAvailable) {
       this.uploadsAvailable = uploadsAvailable;
       * Gets the number of files that have been uploaded.
       * @return
       public int getFileCount() {
       if (getFiles().size() > 0) {
       return getFiles().size();
       } else {
       return 0;
       * Upload event listener for adding files to the list.
       * @param event
       * @throws Exception
       public void listener(UploadEvent event) throws IOException {
       UploadItem item = event.getUploadItem();
       ImageUploadFile file = new ImageUploadFile();
       * Method to get file content.
       * @param stream
       * @param object
       * @throws IOException
       public void paint(OutputStream stream, Object object) throws IOException {
       * Method to clear uploaded files.
       public String clearFileAction() {
       return null;
       * Getter for the upload data
       * @return the uploadData
       public final List<UploadItem> getUploadData() {
       if (null == this.uploadData) {
       this.uploadData = new ArrayList<UploadItem>();
       return uploadData;
       * Setter for the upload data.
       * @param uploadData the uploadData to set
       public final void setUploadData(List<UploadItem> uploadData) {
       this.uploadData = uploadData;

       <display-name>Ajax4jsf Filter</display-name>
       <description>Maximum uploadable file size.</description>
       <description>Creates temporary files on disk.</description>