How to download file in GWT?

33 views
Skip to first unread message

Thai

unread,
Sep 7, 2007, 7:44:10 PM9/7/07
to Google Web Toolkit
I want to create a button so that when it is clicked, it calls a
service which will prepare a file and send it to the client browser.
How can I do that?

Thanks for any of your idea.

Peter Blazejewicz

unread,
Sep 8, 2007, 5:02:36 PM9/8/07
to Google Web Toolkit
hi Thai,

maybe via A tag?

private HTML createDownloadLink(String url, String label) {
StringBuffer toReturn = new StringBuffer("<a ");
toReturn.append("href=\"").append(url).append("\" target=\"_blank
\">");
toReturn.append(label).append("</a>");
return new HTML(toReturn.toString(), false);
}

and then:

rootPanel.add(createDownloadLink("yourfileuri?params", "download
file"));

regards,
Peter

Reply all
Reply to author
Forward
0 new messages