I have a number of places where the user can download a servlet generated 
file. I handle this generically with several steps

1) In my app's HTML, I put an IFRAME

    <!-- Frame for downloading files without opening a new window.   -->
    <iframe src="javascript:''" id="__gwt_downloadFrame" 
style="width:0;height:0;border:0"></iframe>

2) In my app's EntryPoint, I declare

  private static final String DOWNLOAD_IFRAME = "__gwt_downloadFrame";
  private static Frame downloadFrame;
...

Wrap the IFRAME:

  @Override
  public void onModuleLoad() {
    downloadFrame = 
Frame.wrap(Document.get().getElementById(DOWNLOAD_IFRAME));
...

Provide method for downloading

  public static void downloadURL(String url) {
    downloadFrame.setUrl(url);
  }

3) Whenever a download is ready, say in the onSuccess() of an RPC call

  MyApp.downloadURL(url);

On Friday, February 1, 2013 10:57:06 AM UTC-5, membersound wrote:
>
> Hi,
>
> I created a servlet that provides a downloadable file (from String 
> content) by writing to the ServletOutputStream.
> On the client side, I trigger the file download by an Anchor with:
>
> Window.open(GWT.getModuleBaseURL() + "MyServlet", "_blank", "");
>
> It works fine, BUT it seems to open a new browser window, which is somehow 
> directly closed. After this the file download dialog is show.
> How can I prevent this flickering of a new browser window? Can't I achieve 
> this somehow inline?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to