1 2 3 Previous Next 42 Replies Latest reply on Sep 18, 2013 5:09 AM by bhanu246

    richfaces-3.2 - fileUpload

    kaobiore

      Hi!

      I have some problems getting the fileupload with version 3.2.0.CR5 to work.

      It looks like that the listener (in my case: fileUploadListener(UploadEvent event)) is not called at all?!?!

      Environment:
      jboss-4.2.2
      RI-JSF
      richfaces-3.2.0.CR5 (svn)

      Bean:

       private ArrayList<File> files = new ArrayList<File>();
       private int uploadsAvailable = 5;
       private boolean autoUpload = false;
       public int getSize() {
       if (getFiles().size()>0){
       return getFiles().size();
       }else
       {
       return 0;
       }
       }
      
       public void fileUploadListener(org.richfaces.event.UploadEvent event) throws IOException{
       log.error(">>>>>>>>>>>>>>>>>>>>>>>> LISTENER <<<<<<<<<<<<<<<<<<<<<<<<");
       UploadItem item = event.getUploadItem();
       File file = new File();
       file.setLength(item.getData().length);
       file.setName(item.getFileName());
       file.setData(item.getData());
       files.add(file);
       uploadsAvailable--;
       }
      
       public String clearUploadData() {
       files.clear();
       setUploadsAvailable(5);
       return null;
       }
      
       public ArrayList<File> getFiles() {
       return files;
       }
      
       public void setFiles(ArrayList<File> files) {
       this.files = files;
       }
      
       public int getUploadsAvailable() {
       return uploadsAvailable;
       }
      
       public void setUploadsAvailable(int uploadsAvailable) {
       this.uploadsAvailable = uploadsAvailable;
       }
      
       public boolean isAutoUpload() {
       return autoUpload;
       }
      
       public void setAutoUpload(boolean autoUpload) {
       this.autoUpload = autoUpload;
       }
      


      jsp:
       <rich:fileUpload fileUploadListener="#{componentBean.fileUploadListener}"
       maxFilesQuantity="#{componentBean.uploadsAvailable}"
       id="upload"
       listWidth="300"
       listHeight="80"
       immediateUpload="#{componentBean.autoUpload}"
       acceptedTypes="jpg, gif, png, bmp">
       <a4j:support event="onuploadcomplete" reRender="datatable_files" />
       </rich:fileUpload>
      


      Any ideas?

      Thanks!

      -=k=-

        • 1. Re: richfaces-3.2 - fileUpload
          ratoo

          I think you need to add
          uploadData="#{componentBean.files}"

          into the tag, don't ask me why...

          • 2. Re: richfaces-3.2 - fileUpload
            kaobiore

            Hi Ratoo!

            Thanks for your reply ...

            No, does not help.

            Really weired is that if a configure a nonexisting listener in the jsp - I don't even get an error message?!? The listener is not called.

            You have it working ... right? Could you please post you code?

            Thanks!

            -=k=-

            • 3. Re: richfaces-3.2 - fileUpload
              ratoo

              Hello!

              Yes an it works...

              the code itself is huge enough...

              So I'll try to snip it...

              <rich:fileUpload
               fileUploadListener="#{AnySequenceForm.upload}"
               uploadData="#{AnySequenceForm.files}"
               maxFilesQuantity="1"
               immediateUpload="true"
               autoclear="true"
               listHeight="30px"
               fileEntryControlClass="UploaderEntryControlClass"
               uploadListClass="UploaderListClass">
               <a4j:support
               event="onuploadcomplete"
               ajaxSingle="true" reRender="the_sequence_panel"/>
              </rich:fileUpload>
              


              And the bean itself (AnySequenceForm)

              public class AnySequenceForm
              {
               private List files;
               private UploadItem item;
              
               public List getFiles()
               {
               if (files == null)
               {
               files = new ArrayList();
               }
              
               return files;
               }
              
               public void setFiles(List files)
               {
               this.files = files;
               }
              
               public void upload(UploadEvent event) throws IOException
               {
               item = event.getUploadItem();
               ...
               }
              }
              


              DON'T forget
              <h:form enctype="multipart/form-data">
              


              and have a filter in web.xml

               <filter>
               <display-name>Ajax4jsf Filter</display-name>
               <filter-name>ajax4jsf</filter-name>
               <filter-class>org.ajax4jsf.Filter</filter-class>
              
               <init-param>
               <param-name>createTempFiles</param-name>
               <param-value>true</param-value>
               </init-param>
               <init-param>
               <param-name>maxRequestSize</param-name>
               <param-value>20000000</param-value>
               </init-param>
               </filter>
              
               <filter-mapping>
               <filter-name>ajax4jsf</filter-name>
               <servlet-name>Faces Servlet</servlet-name>
               <dispatcher>REQUEST</dispatcher>
               <dispatcher>FORWARD</dispatcher>
               <dispatcher>INCLUDE</dispatcher>
               </filter-mapping>
              


              It works in RC5 (now gonna test in RC6)

              Cheers

              • 4. Re: richfaces-3.2 - fileUpload
                moldovan

                Hy guys!

                I tested the code with CR6, file got uploaded but upload-listener didn't fire!

                • 5. Re: richfaces-3.2 - fileUpload
                  juergen.zimmermann

                  enctype should be omitted from <h:form>

                  • 6. Re: richfaces-3.2 - fileUpload

                     

                    "moldovan" wrote:
                    Hy guys!

                    I tested the code with CR6, file got uploaded but upload-listener didn't fire!



                    Tell me please if you use RF with myfaces or seam framework.
                    In our invironment all fires.

                    • 7. Re: richfaces-3.2 - fileUpload
                      moldovan

                       

                      "Juergen.Zimmermann" wrote:
                      enctype should be omitted from <h:form>


                      no difference between declaring the enctype - attribute or not. listener gets not fired!

                      • 8. Re: richfaces-3.2 - fileUpload
                        moldovan

                         

                        "andrei_exadel" wrote:
                        "moldovan" wrote:
                        Hy guys!

                        I tested the code with CR6, file got uploaded but upload-listener didn't fire!



                        Tell me please if you use RF with myfaces or seam framework.
                        In our invironment all fires.

                        I'm using bundled JSF RI 1.2 Libs from JBoss 4.2.2.GA

                        • 9. Re: richfaces-3.2 - fileUpload
                          ilya_shaikovsky

                          Is it still actual for you using GA version?

                          • 10. Re: richfaces-3.2 - fileUpload
                            moldovan

                            Yes, problem, that listener does not fire, still exists in the RF 3.2.0.GA Release!

                            • 11. Re: richfaces-3.2 - fileUpload
                              ilya_shaikovsky

                              our livedemo example(GA libs) using listener to process uploaded files...

                              • 12. Re: richfaces-3.2 - fileUpload
                                ilya_shaikovsky

                                anyway request sent to FU developer.

                                • 13. Re: richfaces-3.2 - fileUpload

                                  Please provide us more detailed info about the issue. We cannot reproduce this one. Can you post code (pages, beans, webxml) of your application. I think it will help us to find the problem.

                                  • 14. Re: richfaces-3.2 - fileUpload
                                    kaobiore

                                    Hi!

                                    I've sent an email (to andrei and ilya) including a http-link to download a war-file for reproducing this mentioned behavior.

                                    Hope this helps.

                                    Cheers
                                    -=k=-

                                    1 2 3 Previous Next