JSF定时地从应用程序Bean轮询数据库 [英] JSF polling a database from an application bean at timed intervals

查看:69
本文介绍了JSF定时地从应用程序Bean轮询数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是jsf的新手,所以如果这个问题很糟糕,我深表歉意。我目前正在做一个学校项目,我需要通过网络服务访问数据库以获取一些基本的应用程序数据。我有一个通过方法访问此数据,然后从数据库返回最新结果的类。

Hey all, I'm pretty new to jsf so if this is a poor question then I apologize. I'm currently working on a school project where I need to access a database through a web service to get some basic application data. I have a class that accesses this data through a method and then returns the newest results from the database.

我想要做的是生成一个线程,该线程在数据库上调用update方法。 run方法看起来与此类似,在这里我得到了我的应用程序bean,然后在其上调用了refresh方法。

What I want to do is to either spawn a thread that calls the update method on the database. The run method looks similar to this, where i get my application bean and then I call the refresh method on it.

theFacesContext = FacesContext.getCurrentInstance ();

ApplicationBean应用=(ApplicationBean)theFacesContext.getELContext()。getELResolver()。getValue(theFacesContext.getELContext(),null,applicationBean);

app.getDBValues( );

然后线程将基于变量被循环,该变量在应用程序bean被销毁时将被设置为false。我的错误是线程失去了facescontext。我见过一些帖子,人们在这些帖子中说了几句,以使线程保持在请求中,但是我不确定这是什么意思。任何建议都将非常有帮助。

The thread would then loop based on a variable that would be set to false when the application bean was destroyed. My error is that the thread looses the facescontext. I've seen some posts where people say something allong the lines that you have to keep the thread in a request, but I'm not sure what that means. Any suggestions would be extremely helpful.

推荐答案

如果要显示实际数据,则应使用轮询或服务器端推送。有很多Ajax组件可能会有所帮助。查看

PrimeFaces民意调查组件

RichFaces推送

RichFaces民意调查

ICEfaces

If you want to display actual data, you should use polling or server-side push. There are a lot of ajax components that may help. Look at
PrimeFaces poll component
RichFaces push
RichFaces poll
ICEfaces

这篇关于JSF定时地从应用程序Bean轮询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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