java 如何使用 GWT 实现进度条?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6902146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:51:00  来源:igfitidea点击:

How to Implement progressbar with GWT?

javagwtprogress-barrpcgwt-rpc

提问by user405458

In a GWT application, I have a long process that runs server side and invoked using rpc(GWT dispatcher) and I want to have a feedback to the Client as a progress bar showing messages and the total progress. My question is how to recover messages and the progress dynamically from the server?

在 GWT 应用程序中,我有一个很长的进程,它运行服务器端并使用 rpc(GWT 调度程序)调用,我希望向客户端提供反馈作为显示消息和总进度的进度条。我的问题是如何从服务器动态恢复消息和进度?

I'm interested in any solution

我对任何解决方案感兴趣

thank you in advance for your help.

预先感谢您的帮助。

采纳答案by Nico Huysamen

Have a look at the get progress bar in the incubator. Hereis another example of someone using it.

查看孵化器中的 get 进度条。是有人使用它的另一个例子。



UPDATE

更新

If you want to display the progress on the client side, you will need to make async calls to the server periodically to fetch the progress value. In other words, the server needs to write / store somewhere how far it is with its progress. The client then makes an async call to the server, which reads that value and sends it back to the client, which can update the progress bar.

如果要在客户端显示进度,则需要定期对服务器进行异步调用以获取进度值。换句话说,服务器需要在某处写入/存储它的进度。然后客户端对服务器进行异步调用,服务器读取该值并将其发送回客户端,客户端可以更新进度条。

回答by Basanth Roy

A regular Async call should do it. But you will also need to implement some sort of polling mechanism from the client side so that it will send an Async request to the server at periodic intervals.

常规的 Async 调用应该可以做到。但是您还需要从客户端实现某种轮询机制,以便它会定期向服务器发送异步请求。

See the tutorials on Async calls http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html

请参阅有关异步调用的教程 http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html

For the polling mechanism, you should be able to do it with a simple while loop. Inside the while loop, keep calling the getStatus() server call till you get to 100% complete status.

对于轮询机制,您应该可以通过一个简单的 while 循环来完成。在 while 循环中,继续调用 getStatus() 服务器调用,直到达到 100% 完成状态。

回答by Bart

Or you can use the Channel API. It is available in both Python and Java (and probably the other supported langurs as well). https://developers.google.com/appengine/docs/java/channel/

或者您可以使用 Channel API。它在 Python 和 Java 中都可用(可能还有其他支持的叶猴)。 https://developers.google.com/appengine/docs/java/channel/

回答by Nick Siderakis

Taking a look at the progress syncerand progress barfrom upload4gwt might give you some ideas.

查看upload4gwt中的进度同步器进度条可能会给您一些想法。

回答by Chloe

http://www.java2s.com/Code/Java/GWT/GWTprogressbar.htm

http://www.java2s.com/Code/Java/GWT/GWTprogressbar.htm

You must use a timer to periodically poll the server, and keep the progress calculation on the server.

您必须使用计时器定期轮询服务器,并将进度计算保留在服务器上。