1 Reply Latest reply on May 30, 2012 2:41 AM by sadfaces

    Richfaces 4.2.2 HOW TO: set the fileuploadlistener?

    sadfaces

      Based on the 4.x show case, I have:

       

      fileupload.xhtml:

       

      ...
      <rich:fileUpload fileUploadListener="#{fsBean.uploadListener}"
                                                        id="upload"
                                                        maxFilesQuantity="10">
                                                        <a4j:ajax event="uploadcomplete" execute="#{fsBean.doUpload()}" render="info" />
                                              </rich:fileUpload>
      ...
      

       

      fsBean:

       

      @Named("fsBean")
      @Scope("request")
      public class FileServiceBean implements Serializable {
                private List<BpFile> files = new ArrayList<BpFile>();
        
                @Inject
                private IFileService iFileService;
        
                public void uploadListener(FileUploadEvent event) throws Exception {
                          System.out.println("uploadListener");
                          // get the uploaded file from richfaces
                          UploadedFile item = event.getUploadedFile();
        
                          // create the BpFile
                          BpFile file = new BpFile();
                          file.setLength(item.getData().length);
              file.setName(item.getName());
              file.setData(item.getData());
              
              // add the file to upload list
              files.add(file);
                }
        
                public void doUpload() {
                          System.out.println("doUpload()");
                }
        
                public void clearUploadData() {
              files.clear();
          }
      
      ......
      

       

      I ran this webapp in tomcat7, when I was trying to open the page, I got the following error:

       

      javax.el.PropertyNotFoundException: Property 'uploadListener' not found on type abc.xyz.FileServiceBean

       

      Any one here could help please, I am totally new to everything. Thanks heaps in advance.

        • 1. Re: Richfaces 4.2.2 HOW TO: set the fileuploadlistener?
          sadfaces

          ok, so what I have done to pass this exception for testing is super ugly. I added those lines to FileServiceBean:

           

          public void setListener(Object obj){}

          public Object getListener() {return new Object();}

           

          it now works as expected so far. I am not sure if there will be any potentially fatal defects by doing this.

           

          I hope anyone here can provide me a clean solution will be appreciated.