Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Open/Save a File Dialog Box

    Hi All,
    I am new to Smart GWT. I need ur help in exporting a file to PDF. I have implemented RPCService, RPCServiceAsync & RPCServieImpl. On clicking a button a service in server side will be called and it will fetch data from DB and file is created. Once the file is created, then i need to open that file in client side and need to prompt a dialog box with open/save options. how can i implement this opening a file part. pls suggest a way to implement t.. Reply pls.. thanks in advance....
    Last edited by kk8322; 16 Jun 2010, 05:09.

    #2
    You need the response header to contain Content-disposition: attachment; filename=myFile

    Comment


      #3
      @svjard: thanks for ur reply. i understood to set http headers and other config. but these can be setted only in response. i dont have any parameter as response/request. on-clicking a button a user define function in server side impl class is called and all manipulations are done and new file is created. once file is createdi need it to be shown to user. how can make that on-click event to call doget function ??

      Comment


        #4
        I have implemented it.... Thanks for ur help

        Comment


          #5
          I'm facing the same prob.can you please halp me how to open the save as dialog

          Comment


            #6
            Implement a servlet & pass d file/file stream to that servlet response. set the response tyoe as type of output file needed & response header. ex:

            Code:
            resp.setContentType("application/pdf");
            resp.setHeader("Content-Disposition", "attachment; filename=" +docName+".pdf");

            Comment


              #7
              Hi,
              I have a list for files I need to do this to. Let just say the files live on a web server ie. http://esd.download.com/myfile.bin.

              What do I need to do to have all my .bin file to be force download.

              Seem like you wrote a servlet. Pass in the full file path. Then handle the Content-Disposition there?

              Thanks,

              Comment


                #8
                This is my servlet. Does it look correct?

                public void doService(HttpServletRequest request,
                HttpServletResponse response) throws ServletException, IOException {
                response.setHeader("Content-Disposition", "attachment; filename=" +"TDQ5000.0.0setup"+".bin");
                response.sendRedirect("http://downloadesd.com/software/GGT/TDQ/5000/Release/Sol/TDQ5000.0.0setup.bin");

                }

                Comment


                  #9
                  If you redirect like that, your header is ignored because new HTTP request is generated to the URL you are redirecting to. It's the headers on this second HTTP response that matter.

                  Comment


                    #10
                    Hi,

                    Can you please explain how can I direct from the RPCServieImpl to the servlet that returns the PDF with the relevant header?

                    If I didn't understand the solution correctly, please correct me.

                    Thanks,
                    Tali

                    Comment


                      #11
                      This is standard servlets usage unrelated to SmartGWT - this Google search hits several tutorials.

                      Comment


                        #12
                        Hi Admin ... Need to show PDF when i click on some link in listgrid... so please do tell what i need to do in this \case ?

                        Comment

                        Working...
                        X