问题
Thinking to start a project using Spring Web Flow with Primefaces. I need to use comet so i figured Primefaces uses Atmosphere. I'm not really experienced with the Atmosphere / Comet business so any pointers about where to start is welcomed.
Thanks in Advance
回答1:
a very basic example can be found in the primefaces showcase: https://www.primefaces.org/showcase/push/chat.xhtml This is the old example for the ajax push component and is NOT officially included in the show case right now because it will be redone in primefaces 3 if I know right. In addition to that you have to configure the comet servlet within your web.xml:
<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>
If you use primefaces 2.2 you cannot use the newest version of atmosphere/comet I think. I got it running with the following dependencies:
<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>
The last step is to add a file named "atmosphere.xml" within your META-INF directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<atmosphere-handlers>
<atmosphere-handler context-root="/primefaces_comet/*" class- name="org.primefaces.comet.PrimeFacesCometHandler" />
</atmosphere-handlers>
Jens
来源:https://stackoverflow.com/questions/5311853/spring-webflow-primefaces-with-comet-atmosphere