5 Replies Latest reply on Dec 9, 2009 1:53 PM by Eric Ford

    FileUpload component problem

    Eric Ford Newbie

      I am using the rich:fileUpload (3.3.1GA) component in a modalPanel. The first time I upload one or more files the browser tab "busy" indicator (IE 6) continues spinning and never stops. If I reopen the modalPanel and perform another upload then this behavior stops and never occurs again until I reload the page.

      My current attribute settings on the component include: immediateUpload="true", autoclear="true", and maxFilesQuantity="1". However, I've tried different settings for all of these attributes without effect on this problem.

      Any suggestions for what might be causing this would be appreciated.

        • 1. Re: FileUpload component problem
          Eric Ford Newbie

          Oops, make that IE 7 rather than IE 6.

          • 2. Re: FileUpload component problem
            Nick Belaevski Master

            Hi,

            Have you programmed any activity triggered by upload complete, e.g. output of uploaded image, etc.?

            • 3. Re: FileUpload component problem
              Eric Ford Newbie

              Yes. The my listener method converts the UploadItem to a temp file which is then added to an ArrayList and stuffed into the SessionMap. The modalPanel includes two buttons which allow the user to post-process the uploaded files or cancel - in both cases the attribute is cleared from the SessionMap. However, neither removing these buttons nor removing the temp file creation from the listener has any effect on the problem. Even if I stub out the listener method the busy indicator still spins continuously unless I reopen the modalPanel and upload another file.

              • 4. Re: FileUpload component problem
                Ilya Shaikovsky Master

                please show code snippets.

                • 5. Re: FileUpload component problem
                  Eric Ford Newbie

                  Here is the code that defines the modalPanel:

                  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:a4j="http://richfaces.org/a4j"
                   xmlns:rich="http://richfaces.org/rich">
                  
                   <f:facet name="header">Budget Upload</f:facet>
                   <f:facet name="controls">
                   <h:graphicImage value="./images/btn_close_sm.gif"
                   style="cursor:pointer"
                   onclick="Richfaces.hideModalPanel('panelExcelImport')" />
                   </f:facet>
                  
                   <h:form id="excelForm" style="margin:0;">
                   <div id="excelUploadLabel" style="margin-top: 10px; margin-left: 50px; margin-bottom: 0px;">
                   <h:outputText class="modalPanelContent" value="Click BROWSE to select the file to upload." />
                   </div>
                   <rich:fileUpload fileUploadListener="#{excelUploadBean.listener}"
                   maxFilesQuantity="1"
                   id="excelUpload"
                   uploadData="#{excelUploadBean.files}"
                   listHeight = "60"
                   listWidth = "400"
                   immediateUpload="true"
                   autoclear="true"
                   acceptedTypes="xlsx"
                   allowFlash="false"
                   onuploadcomplete="document.forms['excelForm'].reset();document.getElementById('excelForm:excelUpload').style.display='none';document.getElementById('excelUploadLabel').style.display='none';document.getElementById('processUploadMessage').style.display='block';"
                   addControlLabel="Browse">
                   </rich:fileUpload>
                   <div id="processUploadMessage" class="modalPanelContent" style="display:none;">
                   <p style="margin-left:50;margin-top:25;margin-bottom:25">
                   <h:outputText >File uploaded successfully.<br/><br/>Click OK to process data from file.</h:outputText>
                   </p>
                   </div>
                   <div class="modalActionButtons" id="uploadActionButtons" style="width:400px;">
                   <a4j:commandButton id="btnExcelImportSave" reRender="panelExcelImport, panelBudgetExport" status="processStatus2"
                   value="#{msg.okay}" styleClass="actionButton" action="#{Admin_Backing.processBudgetUpload}"/>
                   <rich:componentControl for="panelExcelImport" attachTo="btnExcelImportSave" operation="hide" event="onclick"/>
                   <a4j:commandButton id="btnExcelImportCancel" value="#{msg.cancel}" reRender="panelExcelImport" styleClass="hidelink" style="margin-right:8px;"/>
                   <rich:componentControl for="panelExcelImport" attachTo="btnExcelImportCancel" operation="hide"
                   event="onclick"/>
                   </div>
                   </h:form>
                  </ui:composition>
                  



                  Here is my excelUploadBean.listener() method that processes the uploads:


                   public synchronized void listener(UploadEvent event)
                   {
                   UploadItem item = event.getUploadItem();
                   File file;
                   FileOutputStream fos;
                   try
                   {
                   file = File.createTempFile("excelUpload", ".xlsx");
                   fos = new FileOutputStream(file);
                   fos.write(item.getData());
                   fos.close();
                   List<File> files = getFiles();
                   files.add(file);
                   getSessionMap().put("uploaded.files", files);
                   }
                   catch (IOException e2)
                   {
                   e2.printStackTrace();
                   }
                   }