11 Replies Latest reply on May 21, 2008 7:27 AM by Andrei Markavtsov

    rich:fileUpload problems

    Kto ToTaki Newbie

      1. rich:fileUpload becomes inactive after 1 file upload. Even using minimal with code like

      <rich:fileUpload fileUploadListener="#{testMBean.fileUploaded}" id="fileUpload1">
       </rich:fileUpload>
      

      and the bean code like this:
      public void fileUploaded(org.richfaces.event.UploadEvent event) throws IOException{
       org.richfaces.model.UploadItem item=event.getUploadItem();
       if(item==null) {
       log.error("item==null");
       return;
       }
       log.info("fileUploaded..."+item.getFileName());
       if (item.isFile()) {
       File file = item.getFile();
       log.info("Absolute Path : '" + file.getAbsolutePath() + "'!");
       }else {
       ByteArrayOutputStream b = new ByteArrayOutputStream();
       if(item.getData()!=null){
       b.write(item.getData());
       log.info(b.toString());
       }
       }
       }


      The component becomes inactive after I have pickup the first file. Add button id disabled and there is no possible to get more files, unless using Cancel on the first file.
      It doesn’t help to use onuploadcomplete="this.disabled=false" or with disabled="false"

      What to do to allowed to pickup more then 1 file?

      2. fileUploadListener executes severals times, often with org.richfaces.model.UploadItem item with null content (item.getFile() is null, item.getData() is null...).
      When I placed rich:fileUpload inside h:panelGrid, second execute of fileUploadListener comes with uploaded file.
      But when I placed rich:fileUpload inside rich:modalPanel, fileUploadListener executes twice returning UploadItem with null content.

      How to upload a file when rich:fileUpload is palced inside rich:modalPanel ?