使用JSF如何创建服务器推送变为一个HTML页面? [英] How can server push changes to an HTML page created using JSF?

查看:155
本文介绍了使用JSF如何创建服务器推送变为一个HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们创建了一个JSF页面,客户端请求允许的HTML生成动态使用Java的code和HTML的组合。 我们可以引入在HTML页面挂钩使用JSF框架,允许服务器根据在服务器上发生的事件来更新HTML页面?

When we create a JSF page, a client request allows generation of HTML dynamically using a combination of java code and HTML. Can we introduce hooks in the HTML page using JSF framework, that allow server to update the HTML page based on events occurring at the server?

推荐答案

标准的JSF实现不为此提供内置组件,也未在JSF 2.0。您需要前往的第三方组件库。 ICEfaces的 IcePush PrimeFaces 拥有的 &LT;电话号码:推&GT; 和的 RichFaces的有<一个href="http://docs.jboss.org/richfaces/latest_4_0_X/Component_Reference/en-US/html/chap-Component_Reference-Actions.html#sect-Component_Reference-Actions-a4jpush"相对=nofollow> &LT; A4J:推&GT;

The standard JSF implementation doesn't offer builtin components for this, also not in JSF 2.0. You need to head to 3rd party component libraries. IceFaces has IcePush, PrimeFaces has <p:push> and RichFaces has <a4j:push>.

据彼此的经验,ICEfaces的人似乎更容易安装和运行。我没有与它的经验,但我的经验与PrimeFaces一个是不太好,因为气氛,它在幕后使用,是不是很pretty的设置。它没有明确记载(一堆JAR的,其成分取决于所使用的servletcontainer中走来,但目前尚不清楚哪些是我应该包括/省略为Tomcat和Glassfish的),它有一些问题,在一定serverconfigs(无法获取它曾经对Tomcat的运行)。这是不幸的,因为大气看上去pretty的纸上真棒。自那时以来,事情可能会改变/改善。

According to other's experiences, the IceFaces one seems much easier to setup and run. I don't have experience with it, but my experience with the PrimeFaces one was not so good, because Atmosphere, which it is using under the covers, isn't very pretty to setup. It's not clearly documented (comes along with a bunch of JAR's whose composition depends on the servletcontainer used, it was not immediately clear which ones I should include/omit for Tomcat and Glassfish) and it has some problems at certain serverconfigs (couldn't get it ever to run on Tomcat). That was unfortunate, because Atmosphere looks pretty awesome on paper. Things may have changed/improved since then.

RichFaces4采用大气和JMS的组合(这从而触及的Tomcat从支持的服务器,你需要它支持JMS,比如GlassFish和JBoss AS一个完全成熟的Java EE应用服务器)。你可以找到一个非常详细的的RichFaces的开发商之一,这个博客。我还没有机会尝试,但它看起来不错在纸面上。

RichFaces4 uses a combination of Atmosphere and JMS (this thus scratches Tomcat from the supported servers, you need a full fledged Java EE application server which supports JMS, like Glassfish and JBoss AS). You can find a very detailed Glassfish-targeted tutorial in this blog of one of the RichFaces developers. I haven't had the chance to try it, but it looks good on paper.

另外,您还可以使用推轮询来代替。 pretty的每得多ajaxical JSF组件库有一个&LT; XXX:调查&GT; 成分,是比较容易设置。这使您可以发送exery X秒的AJAX请求到服务器,并在必要时更新内容。

Alternatively, you can also use polling instead of pushing. Pretty much every ajaxical JSF component library has a <xxx:poll> component which is relatively easy to setup. This allows you to send exery X seconds an ajax request to the server and update the content whenever necessary.

这篇关于使用JSF如何创建服务器推送变为一个HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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