1 2 Previous Next 20 Replies Latest reply on May 12, 2010 12:11 PM by kem Go to original post
      • 15. Re: RichFaces fileUpload
        daniele campanini Newbie
        I think you have to put the public void listener in the interface (Upload). I had used a lot of time the <rich:fileUpload tag in this manner and it's work. The exception "Method not found:.." it's common when the interface doesn't have the method.

        • 16. Re: RichFaces fileUpload
          kem Newbie

          Thanks Daniele


          I've tried with and without listener in the interface.
          Always null object.

          • 17. Re: RichFaces fileUpload
            Fabrice ABELLI Newbie

            Hi Khalil,


            I've been working yesterday on uploading pictures with rich:fileupload.
            I can't say that it was not without any difficulties, but I've finally succeeded to do it.
            Some few things I can tell you :


            1) It isn't required to put

            "enctype="multipart/form-data"

            in the h:form. It is required for s:fileUpload, but not for rich:fileUpload. I'd first try to remove it


            2) I have removed

            <web:multipart-filter create-temp-files....>

            in components.xml, and I've kept only :


            <filter>
                <filter-name>Seam Filter</filter-name>
                <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                <init-param>
                    <param-name>createTempFiles</param-name>
                    <param-value>false</param-value>
                </init-param>
                <init-param>
                    <param-name>maxRequestSize</param-name>
                    <param-value>2000000</param-value>
                </init-param>
            </filter>
            



            in web.xml. For me, it was enough.


            3) The value of createTempFile parameter is very important, because of the way you'll read the uploaded object in your action listener depends on it. If you put false for this parameter, you'll receive your data in a byte array (item.getData() in your case), if you put true, richfaces will write the uploaded object in a temporary directory and you'll have to read the uploaded file content to get the data. You can know the temp filename by using item.getFileName().


            4) In your code, you don't seem to use any of this methods. I can see that you have defined your own byte array, and also getter and setter for it, but you never give this byte array a value in your listener.


            Conclusion :


            For simplicity reasons, I would recommend to put the createTempFile parameter to false if your uploaded objects are not too big, and to retrieve the data with item.getData()


            I hope this will help you.

            • 18. Re: RichFaces fileUpload
              kem Newbie

              Thanks Fabrice,


              the getUploadItem still return null object.


              Indeed, I don't assign any value to byte array, as I just want to check if the returned UploadItem is null or not.


              Could you please post your code?


              Regards,
              Khalil

              • 19. Re: RichFaces fileUpload
                Fabrice ABELLI Newbie

                Hi again Khalil,


                There's something strange in your web.xml file.
                Why do you need a RichFaces Filter ? :


                <filter>
                  <display-name>RichFaces Filter</display-name>
                  <filter-name>richfaces</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>2222222</param-value>
                  </init-param>
                 </filter>
                



                I can't see anywhere in the documentation that this filter is required, and in fact, the createTempFiles and MaxRequestSize parameters are at the wrong place. They are supposed to be parameters of the Seam Filter.


                Here is my configuration :


                <filter>
                    <filter-name>Seam Filter</filter-name>
                    <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                    <init-param>
                        <param-name>createTempFiles</param-name>
                        <param-value>false</param-value>
                    </init-param>
                    <init-param>
                        <param-name>maxRequestSize</param-name>
                        <param-value>2000000</param-value>
                    </init-param>    
                  </filter>



                Try to change this to see if it works.



                • 20. Re: RichFaces fileUpload
                  kem Newbie

                  Thanks Fabrice,


                  I agree with you, RichFaces filter is not needed with seam. But I don't think it is harmful if it is present in web.xml.


                  I used your configuration. The problem still the same.


                  Are you using ejb with jboss?

                  1 2 Previous Next