1 2 Previous Next 17 Replies Latest reply on Aug 15, 2013 6:03 AM by dlee606

    Problem with FileUpload RichFaces 4

    r.silva

      Hi...

       

      The following code is not working:

      My .xhtml

      <rich:fileUpload fileUploadListener="#{managerBean.listener}" id="upload" acceptedTypes="gif">

                <a4j:ajax event="uploadcomplete" execute="@none" render="info" />

      </rich:fileUpload>

       

      My Class

       

      @SessionScoped

      @ManagedBean(name="managerBean")

      public class ManagerBean {

                 private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();

         public void listener(FileUploadEvent event){

                       UploadedFile item = event.getUploadedFile();

                       UploadedImage file = new UploadedImage();

                       file.setLength(item.getData().length);

                       file.setName(item.getName());

                       file.setData(item.getData());

                       files.add(file);

                }

                //Getter and Setter

      }

      The listener method is not being invoked!!!

       

      Something is missing or is bug??

       

      Thank's for Help

        • 1. Problem with FileUpload RichFaces 4
          jbalunas

          Are you running MyFaces?  There are known MyFaces issues with file upload.

          • 2. Problem with FileUpload RichFaces 4
            r.silva

            Yes, I'm running MyFaces...

            myfaces-api-2.0.3.jar

            myfaces-impl-2.0.3.jar

             

            Thank's for Help...

            • 3. Problem with FileUpload RichFaces 4
              r.silva

              I found this article:

               

              http://community.jboss.org/wiki/richfileUploadwithMyFaces

               

              ...but RichFaces is for version 3. How does RichFaces to work on version 4??

               

              Thank's

              • 4. Problem with FileUpload RichFaces 4
                jbalunas

                Unfortunatly for MyFaces and RichFaces 4, we need updates in MyFaces.  We'll keep an eye on it, and update when it is available.

                 

                -Jay

                • 5. Re: Problem with FileUpload RichFaces 4
                  t_guen03

                  Hi,

                   

                  I have the same problem. But I use Mojarra instead of MyFaces.


                  Following my setup:

                   

                  <rich:fileUpload fileUploadListener="#{uploadBean.test}"
                                  id="upload" acceptedTypes="jpg, gif, png, bmp" />
                  

                   

                  void test(FileUploadEvent event) throws Exception {
                          UploadedFile file = event.getUploadedFile();
                          System.out.println("Uploaded : " + file.getName());
                      }
                  

                   

                  If i add an item to the fileupload component and click upload, nothing happens.

                   

                  It would be very nice if someone could tell me, whats the reason for this.

                   

                  Thanks for your help

                  • 6. Problem with FileUpload RichFaces 4
                    adamo901

                    I also have the same problem using Glassfish 3.1 (with Mojarra 2.1)

                     

                    The progress bar is showen but doesn't start even if the function:

                     

                    public void listener(FileUploadEvent event) throws Exception {}

                     

                    is working perfectly!!!!!

                     

                    Is there any thing I can do?

                    • 7. Problem with FileUpload RichFaces 4
                      ilya_shaikovsky

                      you using Final version? Any JS errors?

                      • 8. Problem with FileUpload RichFaces 4
                        adamo901

                        I am using the final version of Richfaces4.0 and I get no js error

                         

                        There is only one tag in my xhtml page :

                         

                        <html xmlns="http://www.w3.org/1999/xhtml"
                                 xmlns:h="http://java.sun.com/jsf/html"
                                 xmlns:rich="http://richfaces.org/rich" >
                            <h:body>
                                  <h:form>
                                           <rich:fileUpload fileUploadListener ="#{fileUploadBean2.load}"/>
                                   </h:form>
                            </h:body>
                        </html>

                        Every thing is displayed correctly except the progress bar that is showen when I click on upload but doesn't change and remains empty even if the file is well uploaded by :

                         

                         

                        import javax.enterprise.context.SessionScoped;

                        import javax.inject.Named;

                         

                        @Named

                        @SessionScoped

                        public class FileUploadBean2 implements Serializable {

                         

                            public void load(FileUploadEvent event) throws Exception {

                         

                                UploadedFile item = event.getUploadedFile();

                                try {

                                    DataInputStream in = new DataInputStream(item.getInputStream());

                                    BufferedReader br = new BufferedReader(new InputStreamReader(in));

                                    String strLine;

                                    while ((strLine = br.readLine()) != null) {

                                           / / some processing that behaves correctly!!

                                    }

                                    in.close();

                                } catch (Exception ex) {

                         

                                    System.out.println(ex);

                         

                                }

                            }

                         

                        }

                         

                        Can you please help about this!

                        • 9. Re: Problem with FileUpload RichFaces 4
                          ahmed_samir

                          @Ilya ....

                             really i used your code on the richfaces show case ...

                          but when i tried it on my machine  it give me some out put ..

                          <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"

                                                           id="upload" acceptedTypes="jpg, gif, png, bmp">

                                                                  <a4j:ajax event="uploadcomplete" execute="@none" render="uploadPanel" />

                                          </rich:fileUpload>


                          public void listener2(FileUploadEvent event) throws Exception {

                                  System.out.println("loadingfile");

                                  UploadedFile file = event.getUploadedFile();

                                  String invoiceFile = file.getName();

                                  System.out.println("fileInformation loaded = " + invoiceFile);

                              }

                          it actually give me the file name .. but the upload file componenet didn't change  ...

                          and in another code ... i copied the file from stream to the image directory and it was perfect ... but still the problem whith in the component

                          so can you please help me about this ... i used prime faces ... but it didn't give me any respone .. event any action from the fileUploadBean

                          • 10. Re: Problem with FileUpload RichFaces 4
                            ilya_shaikovsky

                            please create simple war sample(or maven based project sources would be ideal).. should be something obvious in configuration I guess.. we will run it locally and check..

                             

                            then you could attach there or crete jira issue and place there.

                            • 11. Re: Problem with FileUpload RichFaces 4
                              ahmed_samir

                              ok ilya ... here is the war file ... it give the name of the file in the output screen .

                              I use netbeans 7.0 ....

                              and I depoly it on  tomcat 7.0.12

                              • 12. Re: Problem with FileUpload RichFaces 4
                                ahmed_samir

                                ok ilya here is the war file ... I removed the libraries from the war file for size purpose... and you will find an image contains libraries name ..

                                so notify my if i was using a wrong version .

                                and you will find the  beans I was using in .java files

                                • 13. Re: Problem with FileUpload RichFaces 4
                                  ilya_shaikovsky

                                  at first I do not see RF fileUpload used across pages.. only PF one. but anyway - had one more suggestion - please try it out without PF added to the project. If will works fine - it means that there is some compatibility problems. (maybe for example both libs bases on jQuery but has different versions or something like that). Then if so create an issue for that particular compatibility case.

                                  • 14. Re: Problem with FileUpload RichFaces 4
                                    ahmed_samir

                                    great ilya ... Thank you very much .... any way the pf component was not working with me ... I expected that but I didn't know why they reflect together .

                                    any way thnx 4 your support.

                                    1 2 Previous Next