GWT - 在加载文件之前,最简单的加载屏幕的方法 [英] GWT - easiest way to do a simple loading screen until file is loaded

查看:112
本文介绍了GWT - 在加载文件之前,最简单的加载屏幕的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当点击一个按钮时,我的GWT应用程序返回嵌入HTML页面中的PDF文件,如下所示:

When clicking a button, my GWT application returns a PDF file embedded in an HTML page which looks something like:

<html><head></head>
<body marginwidth="0" marginheight="0" bgcolor="rgb(38,38,38)">
<embed width="100%" height="100%" name="plugin"
    src="http://myserver/?cmd=getMyPdf" type="application/pdf">
</body>
</html>

问题是服务器可能需要一段时间才能创建此PDF文件,所以我想要的是一个带有加载动画的等待屏幕,可以在后台下载PDF文件,然后当文件完成后,如上所述显示页面。

Problem is it can take a while for the server to create this PDF file, so what I want is a waiting screen with a loading animation which can have the PDF file download in the background, and then when the file is done, display the page as described above.

一个明显的方式是显示一个加载页面,向服务器发送一个异步命令,然后一旦调用了onSucceed方法,就像正常调用页面一样。缺点是我必须添加一些服务器端的逻辑,使PDF创建工作在后台...

One obvious way would be to display a loading page, send an asynchronous command to the server and then once the onSucceed method is called, call the page as normal. Downside is I'd have to add some server-side logic for making the PDF creation work in the background...

有没有办法做这个客户端与GWT API?

Is there any way to do this client-side with the GWT API?

推荐答案

你看到这个stackoverflow问题浏览器接收文件下载时检测?基本上给出的答案是您在返回响应中设置一个cookie,并在客户端等待该cookie被设置。这可以很容易地与GWT一起完成,因为它具有一个Scheduler(用于重复定时器检查),并且可以方便地访问Cookies。您仍然需要进行一些服务器更改,但您不必创建后台进程。

Did you see this stackoverflow question Detect when browser receives file download? Basically the answer given is that you set a cookie in the return response and wait on the client side for this cookie to be set. This can be done easily with GWT as it has a Scheduler (for the repeated timer check) and easy access to Cookies. You still need to make some server changes, but you don't have to create a background process.

这篇关于GWT - 在加载文件之前,最简单的加载屏幕的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆