考虑使用带有 Primefaces 的 Spring Web Flow 开始一个项目。我需要使用彗星,所以我认为 Primefaces 使用 Atmosphere。我对 Atmosphere / Comet 业务并没有真正的经验,所以欢迎任何关于从哪里开始的指示。
提前致谢
考虑使用带有 Primefaces 的 Spring Web Flow 开始一个项目。我需要使用彗星,所以我认为 Primefaces 使用 Atmosphere。我对 Atmosphere / Comet 业务并没有真正的经验,所以欢迎任何关于从哪里开始的指示。
提前致谢
可以在 primefaces 展示中找到一个非常基本的示例:https ://www.primefaces.org/showcase/push/chat.xhtml 这是 ajax 推送组件的旧示例,目前尚未正式包含在展示案例中因为如果我知道的话,它将在 primefaces 3 中重做。除此之外,您还必须在 web.xml 中配置 comet servlet:
<servlet>
<servlet-name>Comet Servlet</servlet-name>
<servlet-class>org.primefaces.comet.PrimeFacesCometServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.useBlocking</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Comet Servlet</servlet-name>
<url-pattern>/primefaces_comet/*</url-pattern>
</servlet-mapping>
如果你使用 primefaces 2.2,我认为你不能使用最新版本的大气/彗星。我使用以下依赖项运行它:
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-compat-tomcat</artifactId>
<version>0.5</version>
</dependency>
最后一步是在 META-INF 目录中添加一个名为“atmosphere.xml”的文件,其内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<atmosphere-handlers>
<atmosphere-handler context-root="/primefaces_comet/*" class- name="org.primefaces.comet.PrimeFacesCometHandler" />
</atmosphere-handlers>
延斯