GWT browse to select the directory

508 views
Skip to first unread message

Puneeth

unread,
May 28, 2008, 12:53:16 AM5/28/08
to Google Web Toolkit
Hi

In my application I am creating a xml file and I want to save it
in the directory specified by the user, so I want to implement a
browse button to select the directory to save the file.

Same as when you click “save as” button while downloading a file from
internet.

Reinier Zwitserloot

unread,
May 28, 2008, 10:40:23 AM5/28/08
to Google Web Toolkit
You can't. That part is entirely done by the browser.

GWT can't fix this, and it will NEVER become part of webbrowsers.
Ever. The moment I can traverse your local filesystem's directories is
the moment I will scan your entire disk for your passwords in the
background. It's a fundamental security risk that browsers won't ever
have. Or if they do, it'll be big news and that browser's author will
scramble to close that hole and push out a patch ASAP.

Create the XML file on the server (or push it to the server), then
have a 'download' link, which is served up with the mime type
"application/force-download" (ugly, but that works). When users click
it, the browser will open the save as dialog.

It's impossible to save a data stream you have on the client (in GWT
code) to the user's disk without server involved. This bit might
eventually be addressed by web browser authors, but it's not on the
horizon (read: in the proposed specs for HTML5), so don't hold your
breath.

blain

unread,
May 28, 2008, 1:38:03 PM5/28/08
to Google Web Toolkit
I slightly agree with the above post. Yes allowing client side access
breaks fundamental security rules enforced by javaScript you can still
program in ActiveX (require IE) to do those type of features (I would
never program ActiveX and don't know any that willingly would).

However, I read that description a little differently and interpreted
that he would like to create a file and store it in a directory on the
server. In that case your looking at reading a directory structure on
the server, passing it to the client, and implementing a folder
explorer type widget. I would be very careful about what is made
available.

Puneeth

unread,
Jun 25, 2008, 7:31:32 AM6/25/08
to Google Web Toolkit

Yes I am creating a file and want to store it in a directory on the
server. I am looking at reading a directory structure on

walden

unread,
Jun 25, 2008, 9:01:25 AM6/25/08
to Google Web Toolkit
Ok, so in the click listener of the browse button, you fire off an rpc
request which returns with the filesystem info as a tree of java
objects, and you use those to render a GWT Tree in a panel you create
for that purpose. If you also need to manage different versions of
your xml file, you might as well chuck your GWT application and just
go with Subversion, which is already written and tested and is free!

Walden
Reply all
Reply to author
Forward
0 new messages