Announcement

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

    File upload and download

    hi ,

    I want to upload and download the file ,can any one guide me how to do, I searched in showcase no such example is there.I'm not using any framework like structs ,spring ...etc


    Regards,
    Stanley

    #2
    For upload from SmartGWT, u can use the uploadItem or FileItem inside a DynamicForm and submit it which is sent back to the server as a multipart form.

    On the backend you could use the Apache Commons FileUpload API to access the uploaded file. I have a REST backend and it works... so I guess this API works on any server code.

    Cheers,
    Hetal

    Comment


      #3
      SmartGWT Enterprise Edition (EE) supports both, upload and download (export) pretty much without any code.

      Have a look at the export sample and the file upload sample.

      The file upload functionality is very sophisticated and not only does it report data validation errors back to the user, but also allows them to correct the invalid data and resubmit to the server. All this is in-built and no additional coding is required.

      Comment


        #4
        File Upload and download

        hi,

        thx for reply , but i'm not using smartgwt EE , can you suggest me how to do in smartgwt . Please do the needful .


        Regards
        Stanley

        Comment


          #5
          See Hetal's response above.

          Sanjiv

          Comment


            #6
            File upload and download

            hi Hetal,
            Thanks for the help , implemented what you have said ,it's worked fine


            Regards
            Stanley

            Comment


              #7
              Originally posted by hgaglani
              For upload from SmartGWT, u can use the uploadItem or FileItem inside a DynamicForm and submit it which is sent back to the server as a multipart form.

              On the backend you could use the Apache Commons FileUpload API to access the uploaded file. I have a REST backend and it works... so I guess this API works on any server code.

              Cheers,
              Hetal
              Hi Hetal,

              How can I export/download the ListGrid data in csv(Excel) format by just using smart GWT & not smart EE?

              I tried to do ListGrid.exportData() but no results

              DSRequest dsRequestProperties = new DSRequest();
              dsRequestProperties.setExportAs((ExportFormat)EnumUtil.getEnum(ExportFormat.values(), "csv"));
              dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
              listGrid.exportData(dsRequestProperties);

              Please suggest.
              Thanks,
              Yasmeen

              Comment


                #8
                Hi steve,

                You've got solution for upload and download the file, ryt?

                can you send code for upload and download the file?
                Or
                What all stepts to be done for the upload and download the file?

                Thanks,
                Leo

                Comment


                  #9
                  Originally posted by sjivan
                  See Hetal's response above.

                  Sanjiv

                  Hi Sanjiv,


                  How can I export/download the ListGrid data in csv(Excel) format by just using smart GWT & not smart EE?

                  The following did not work for me.

                  DSRequest dsRequestProperties = new DSRequest();
                  dsRequestProperties.setExportAs((ExportFormat)EnumUtil.getEnum(ExportFormat.values(), "csv"));
                  dsRequestProperties.setExportResults(true);
                  dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
                  listGrid.exportData(dsRequestProperties);
                  Please help.

                  Thanks in advance

                  Comment


                    #10
                    Oh my.. this is the third thread talking about csv export in smartgwt and not EE version....

                    here I go again:
                    I created a simple sample that exports a listgrid into csv data. From there you just need to send the string containing csv data to server, etc...
                    http://forums.smartclient.com/showthread.php?t=6788

                    Comment


                      #11
                      Originally posted by mihai007
                      Oh my.. this is the third thread talking about csv export in smartgwt and not EE version....

                      here I go again:
                      I created a simple sample that exports a listgrid into csv data. From there you just need to send the string containing csv data to server, etc...
                      http://forums.smartclient.com/showthread.php?t=6788

                      Thanks a lot Mihai007.

                      Comment


                        #12
                        Originally posted by ynaik
                        Thanks a lot Mihai007.

                        When to try to write to excel file using APACHE POI at the server side,I get the following exception

                        Here is the code at GWT RPC ServiceImpl side,

                        response = getThreadLocalResponse();
                        response.setContentType("application/vnd.ms-excel");
                        HSSFWorkbook wb = new HSSFWorkbook();
                        HSSFSheet sheet = wb.createSheet("new sheet");

                        // Write the output
                        OutputStream out = response.getOutputStream();
                        wb.write(out);
                        out.close();


                        here is the Exception


                        2009-07-29 13:04:25,659 [ERROR] exportData
                        com.google.gwt.core.client.JavaScriptException:
                        (Error): Could not complete the operation due to error c00ce514.
                        number: -1072896748
                        description: Could not complete the operation due to error c00ce514.
                        at com.google.gwt.http.client.XMLHTTPRequest.getResponseText(Native Method)
                        at com.google.gwt.http.client.Request$1.getText(Request.java:74)
                        at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:185)
                        at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:264)
                        at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:236)
                        at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:227)


                        Why am i getting this exception

                        Could not complete the operation due to error c00ce514.



                        Please help.
                        Last edited by ynaik; 29 Jul 2009, 09:07.

                        Comment


                          #13
                          Originally posted by ynaik
                          When to try to write to excel file using APACHE POI at the server side,I get the following exception

                          Here is the code at GWT RPC ServiceImpl side,

                          response = getThreadLocalResponse();
                          response.setContentType("application/vnd.ms-excel");
                          HSSFWorkbook wb = new HSSFWorkbook();
                          HSSFSheet sheet = wb.createSheet("new sheet");

                          // Write the output
                          OutputStream out = response.getOutputStream();
                          wb.write(out);
                          out.close();


                          here is the Exception


                          2009-07-29 13:04:25,659 [ERROR] exportData
                          com.google.gwt.core.client.JavaScriptException:
                          (Error): Could not complete the operation due to error c00ce514.
                          number: -1072896748
                          description: Could not complete the operation due to error c00ce514.
                          at com.google.gwt.http.client.XMLHTTPRequest.getResponseText(Native Method)
                          at com.google.gwt.http.client.Request$1.getText(Request.java:74)
                          at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:185)
                          at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:264)
                          at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:236)
                          at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:227)


                          Why am i getting this exception

                          Could not complete the operation due to error c00ce514.



                          Please help.

                          I have written another Servlet that handles that File download, when i test the URL standalone, it works fine, but when i try to invoke using smartGWT , nothing happens, i mean the call is not invoked . This is not thru RPC Manager

                          code
                          final DynamicForm form = new DynamicForm();
                          form.setEncoding(Encoding.MULTIPART);
                          form.setCanSubmit(true);
                          form.setAction(GWT.getModuleBaseURL()+"fileServlet");
                          form.submit();

                          Please help, How can I invoke a url , response.contentType of FileServlet is "application/vnd.ms-excel" .

                          Comment


                            #14
                            First, you cannot use GWT-RPC / Ajax to upload / download a file.

                            Use Fiddler / Firebug to see the URL being invoked when you're using the servlet.

                            Comment


                              #15
                              Originally posted by hgaglani
                              For upload from SmartGWT, u can use the uploadItem or FileItem inside a DynamicForm and submit it which is sent back to the server as a multipart form.

                              On the backend you could use the Apache Commons FileUpload API to access the uploaded file. I have a REST backend and it works... so I guess this API works on any server code.

                              Cheers,
                              Hetal

                              Hi Hetal,

                              How can I populate the smart GWT ListGrid with the data present in the upload file? Please suggest.

                              Comment

                              Working...
                              X