GWT - 做一个简单的载入画面最简单的方法,直到文件被加载 [英] GWT - easiest way to do a simple loading screen until file is loaded

查看:617
本文介绍了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?

推荐答案

你有没有看到这个计算器问题的检测时,浏览器接收文件下载?基本上给出的答案是,你设置在返回响应的cookie,并在客户端等待这个cookie进行设置。这很容易与GWT做,因为它有一个调度器(用于重复计时器检查),并方便地访问缓存数据。你仍然需要做一些服务器更改,但你不必创建一个后台进程。

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天全站免登陆