1 Reply Latest reply on Apr 27, 2010 7:16 PM by Mario De Frutos

    rich:fileUpload First request isn't triggered

    pi tee Newbie

      hi,


      i have a rich:fileUpload component in my app...


      it works just fine, BUT, in some cases the first fileUpload request isn't triggered..


      has anyone an idea?




      <r:fileUpload fileUploadListener="#{materialCreate.imageListener}" listHeight="120"
              immediateUpload="true" autoclear="true" acceptedTypes="tga" maxFilesQuantity="5"
              listWidth="160" ajaxSingle="true" allowFlash="false">
              <f:facet name="label">
                      <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
              </f:facet>
              <a:support event="onuploadcomplete" reRender="fileInfo" />
      </r:fileUpload>




      and here my listener...


      public void imageListener(UploadEvent event) {
                      log.debug("Method imageListener() called");
                      
                      UploadItem uploadItem = event.getUploadItem();
                      
                      // eventually needed for image upload if no temporary files will be created
                      if (uploadItem.getData() != null) {
                              log.debug("Filesize of uploadItem: #0", uploadItem.getFileSize());
                      }
                      
                      if (uploadItem.isTempFile()) {
                              File file = uploadItem.getFile();
                              log.debug("Absolute file path: #0", file.getAbsolutePath());
                              
                              // make instance
                              Image image = new Image();
                              
                              image.setTimestamp(new Date());
                              image.setHidden(0);
                              image.setDeleted(0);
                              image.setContenttype(ApplicationSettings.instance().getImageOriginalContentType());
                              //image.setContenttype(uploadItem.getContentType());
                              image.setImage(file.getAbsolutePath());
                              image.setUser(user.getUid());
                              
                              // add to images
                              images.add(image);
                              log.debug("Images size: #0", images.size());
                              
                      } else {
                              log.warn("Uploaded item is not a file!");
                      }
              }