9 Replies Latest reply on Mar 29, 2011 8:50 AM by jobmathew

    How to get the path of the uploaded files richface

    jobmathew

      Hi All,

       

      Am using richface and trying to upload some files.

       

      my web.xml is not configured for createTempFile which means the value of createTempFile is true

       

      In the temporary folder (depends on OS) if the value of the                        createTempFile parameter in Ajax4jsf                        Filter (in web.xml) section is "true" (by Default)

       

      How can i get the temp path of the uploaded file ????

       

      or how can i get the path of the uploaded files ??

        • 1. Re: How to get the path of the uploaded files richface
          iabughosh

          Dear Job,

           

          add fileUploadListener to your component, here is the ex :

          <rich:fileUpload style="width:40%"

                                                                                                     doneLabel="Done"

                                                                                                     progressLabel="Uploading..."

                                                                                                     autoclear="true"

                                                                                                     uploadData="#{RichBacking.richBean.uploadFiles}"

                                                                                                     fileUploadListener="#{RichBacking.fileUploadListener}"

                                                                                                     maxFilesQuantity="4"

                                                                                                     immediateUpload="false"

                                                                                                     noDuplicate="true"                                                                                          

                                                                                                     listHeight="50"/>

           

          your listener :

          public void fileUploadListener(UploadEvent ue) {

                              String filePath = ue.getUploadItem().getFileName();

          }

          • 2. Re: How to get the path of the uploaded files richface
            jobmathew

            i have tried it

             

            am getting only the file name not the path of the file.

            • 3. Re: How to get the path of the uploaded files richface
              iabughosh

              sorry job,

              try this :

              String filePath = ue.getUploadItem().getFile().getPath();

               

              Regards

              • 4. Re: How to get the path of the uploaded files richface
                jobmathew

                am getting the below NP exception

                 

                29.03.2011 14:02:34 com.sun.faces.lifecycle.ApplyRequestValuesPhase execute

                WARNUNG: /Resource/FileUpload.xhtml @11,98 fileUploadListener="#{fileUpload.listener}": java.lang.NullPointerException

                javax.faces.el.EvaluationException: /Resource/FileUpload.xhtml @11,98 fileUploadListener="#{fileUpload.listener}": java.lang.NullPointerException

                • 5. Re: How to get the path of the uploaded files richface
                  jobmathew

                  IN debuging i saw that the file inside the upload event is "NULL"

                  • 6. Re: How to get the path of the uploaded files richface
                    iabughosh

                    please post the full stacktrace.

                    • 7. Re: How to get the path of the uploaded files richface
                      jobmathew
                      • 8. Re: How to get the path of the uploaded files richface
                        iabughosh

                        try adding this attribute

                        immediateUpload="true"

                         

                        if this is not working please attach the full trace &  your web.xml.

                        • 9. Re: How to get the path of the uploaded files richface
                          jobmathew

                          I got fixed it.

                           

                          The probem was like in web.xml the

                           

                          createTempFile was set to false.