简体   繁体   English

如何从JavaBean刷新jsf页面

[英]how to refresh a jsf page from a JavaBean

I want to refresh an XHTML page (jsf) or part of this page, when a variable in a manageBean changes the value. 当manageBean中的变量更改值时,我想刷新XHTML页面(jsf)或该页面的一部分。

The problem is: 问题是:

I have a JavaBean, which receives data from a webService. 我有一个JavaBean,它从webService接收数据。 This data changes regularly. 此数据定期更改。 when a variable changes value, I want to display it in the IHM page. 当变量更改值时,我想在IHM页面中显示它。

I want that my application detects these changes and refresh the page automatically. 我希望我的应用程序检测到这些更改并自动刷新页面。

Thank you. 谢谢。

Use ajax polling. 使用ajax轮询。 Demos: 演示:

Note that RichFaces 3.3 works with JSF 1.2 and JSF 2, RichFaces 4.x and PrimeFaces 3.x works with JSF 2.x 请注意,RichFaces 3.3与JSF 1.2和JSF 2一起使用,RichFaces 4.x和PrimeFaces 3.x与JSF 2.x一起使用。

One quick way would be to use a third-party library like PrimedFaces 一种快速的方法是使用像PrimedFaces这样的第三方库

This library includes a component called poll with wich you can check your backend in a preset interval and update your view component(s) on changes. 该库包含一个名为poll的组件,您可以在预设的时间间隔内检查后端并在更改时更新您的视图组件。
Check out the link to see an easy example. 查看链接以查看简单示例。

Hope this helpes. 希望这会有所帮助。 Have Fun! 玩得开心!

您可以在jsf中使用ajax的poll选项,例如

<a4j:poll interval="timeinms" reRender="jsfcomponent"> </a4j:poll>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM