to  save data as a file, you will need to passs the client data to
server and server send back the data to download as a cvs.

On May 5, 12:30 pm, "cho.cabot" <[email protected]> wrote:
> I am trying to allow a user to download data he has manipulated in a
> GWT application in CSV format by clicking a button.  I do not want to
> have to go back to the server to create/download this CSV file since I
> already have the data I need for the file in the client.  I did not
> see a way to accomplish this in the GWT API, so I went the native
> JavaScript route.  I created these methods:
>
> private native Object exportOpen() /*-{
>         var win = window.open("", "export", "");
>         var doc = win.document;
>         doc.open("text/csv", "replace");
>         return win;
>
> }-*/;
>
> private native void exportWrite(Object win, String line) /*-{
>         win.document.writeln(line);
>
> }-*/;
>
> private native void exportClose(Object win) /*-{
>         win.document.close();
>
> }-*/;
>
> And when a button is clicked, the following method is called:
>
> private void export() {
>         Object win = exportOpen();
>         // Actual code loops through data and writes lines, but for
> example...
>         exportWrite(win, "TEST,TEST,TEST");
>         exportClose(win);
>
> }
>
> This code basically works, except for the fact that the output is just
> displayed in a new browser window without prompting the user with the
> open/save dialog, which is what I was after.
>
> Does anyone know how I can get the open/save dialog to be opened for
> the user?  Or, is there a way to create and download this data in GWT
> without using native JavaScript?
>
> Thanks for your help.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to