如何监控异步/后台线程的状态,并在JSF组件收到通知 [英] How to monitor asynchronous/background thread status and get notifications in a JSF component

查看:190
本文介绍了如何监控异步/后台线程的状态,并在JSF组件收到通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中创建的线程数,我在JSF页面的DataTable组成部分。

我想自动更新该表,以显示线程的当前状态。是否有任何prebuild分量,我可以在这种情况下使用?


解决方案

  

我在Web应用程序中创建线程数


我衷心希望你did它从而以正确的方式是不史诗灾难告终。



  

我想自动更新该表,以显示线程的当前状态。是否有任何prebuild分量,我可以在这种情况下使用?


你基本上找一个所谓的投票或推技术。轮询的基本概念是使用JavaScript的的setInterval()的setTimeout()来火(AJAX)的HTTP请求向间隔服务器并让它相应的处理结果。推的基本概念是打开一个持久的HTTP连接,并具有该服务器在发送小消息,这是可以做到的等等<一个href=\"https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications\"相对=nofollow> 的WebSocket 在JavaScript中和的 JSR356 API中的Java EE 7

标准JSF实现不提供任何现成使用轮询或推组件开箱。对于即将到来的JSF 2.3,新的&LT; F:WebSocket的&GT; 标签是目前正在进行中(另见的问题1396 )。

您最好的选择是一个隐藏的表单与一个隐藏的命令链接/按钮&LT; F:AJAX&GT; ,然后通过的setInterval调用它()。如 PrimeFaces 组件库提供但随时可以使用的组件开箱,也见的 &LT;电话号码:调查&GT; 展示和的 &LT;电话号码:推&GT; 展示对一些具体的例子。 JSF工具库 OmniFaces 在它的 &LT;○:commandScript&GT; 展示一项民意调查为例,在的 &LT;○:插座&GT; 展示几个推例子(新标准JSF &LT;˚F :WebSocket的&GT; 将在很大程度上基于&LT;○:插座&GT;

参见:

I created few threads in a web application and I have a datatable component in JSF page.

I would like to update the table automatically to show the current status of thread. Is there any prebuild component I can use in this scenario?

解决方案

I created few threads in a web application

I wholeheartedly hope that you did it the right way and thus it don't end up in an epic disaster.


I would like to update the table automatically to show the current status of thread. Is there any prebuild component I can use in this scenario?

You're basically looking for a technique called "polling" or "pushing". The basic concept of polling is to use JavaScript's setInterval() or setTimeout() to fire a (ajax) HTTP request to the server at intervals and let it process the results accordingly. The basic concept of pushing is to open a persistent HTTP connection and have the server send small messages over it, this can be done with among others WebSocket in JavaScript and JSR356 API in Java EE 7.

The standard JSF implementation doesn't offer any ready-to-use poll or push component out the box. For the upcoming JSF 2.3, a new <f:websocket> tag is currently in progress (see also issue 1396).

Your best bet would be a hidden form with a hidden command link/button with <f:ajax> and then invoke it by setInterval(). Component libraries like PrimeFaces however offer ready-to-use components out the box, see also <p:poll> showcase and <p:push> showcase for some concrete examples. JSF utility library OmniFaces has in its <o:commandScript> showcase a poll example and in <o:socket> showcase several push examples (the new standard JSF <f:websocket> will be largely based on <o:socket>).

See also:

这篇关于如何监控异步/后台线程的状态,并在JSF组件收到通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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