Spring Webflow , Primefaces with Comet (Atmosphere) - comet

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

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

Related

Cannot find theme.css resource of AdminFaces

I'm using PrimeFaces 6.0 to develop a business application. Now my UI looks very primitive. I just want to re-design it by using AdminFaces templates (1.0.0-RC18).
I don't have any idea about this, can anyone can help me to solve my issue. How I can implement this template in to my project.
When I add the AdminFaces theme to my project by using following code, I get an error.
pom.xml:
<dependency>
<groupId>com.github.adminfaces</groupId>
<artifactId>admin-template</artifactId>
<version>1.0.0-RC18</version>
</dependency>
<dependency>
<groupId>com.github.adminfaces</groupId>
<artifactId>admin-theme</artifactId>
<version>1.0.0-RC18</version>
</dependency>
web.xml:
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>admin</param-value>
</context-param>
the error:
cannot find "theme.css" resource of "primefaces-admin-1.0.0-rc18" library

"This XML file does not appear to have any style information..." Primefaces Error

It seems an old qs , but i am not getting any proper suggestion.
Steps to produce error :
Scenario One :
1 : Logging in two tabs of same browser with same user credential.
2 : Logging out from one tab .
3 : Logging in again.
I am seeing : This XML file does not appear to have any style information......,
<?xml version="1.0" encoding="UTF-8" ?>
- <partial-response id="j_id1">
- <changes>
- <update id="j_id1:javax.faces.ViewState:0">
- <![CDATA[ 1ZFe3NbsDVn3BWdUDEmAPV96v XXXXXXXX...]]>
</update>
</changes>
</partial-response>
Scenario 2 :
The same error when the restart tomcat and logging in .
Please suggest me How to fix this.
My Web.xml content :
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
I m using Primeface 4 with jsfVersionMojarra-2.1.26 also 2.2.4 Even i am shocked why both versions are in my pom. Anyway this i will check.) . But i am pretty sure this will not cause this issue.

Can't access static resources (.html) files in Apache Tomcat 7.0.52

Even though I found some similar queries on the topic but can't find any answer suitable to my problem. My requirement is as follows -
I have installed my app (MyApp) in webapps dir of Apache Tomcat ver 7 web server. The dir structure is
/
|
|----api/
|
|----WEB-INF/
|
|----META-INF/
I have some static html files in the "api" dir(say index.html) which I want to access in the following way through a browser - http://localhost:8080/myapp/api/index.html
However, I can't access any static resources (html files) in this way. As far as I know any static outside WEB-INF can be accessed directly through the browser but I can't do it.
My web.xml looks something like this -
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>MyApp</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>com.mycomp.MyApp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
I'll appreciate any good help on this.
Thanks.
Try replacing the value for the tag url-pattern with some different name like /rest/* instead of myapp.
Now try accessing your url.

JRuby Rack - How to add a servlet filter?

I'm trying (with no success) to pass the response of a JRuby Rack - Rails application to a filter in order to get it processed. Basically I want to use the Orbeon XForm Engine to enhance the XHTML output coming from my Rails application. If I use a simple Java servlet instead on JRuby Rack everything works smoothly.
Here's the web.xml file:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>public.root</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>rails.env</param-name>
<param-value>production</param-value>
</context-param>
<context-param>
<param-name>jruby.min.runtimes</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>jruby.max.runtimes</param-name>
<param-value>4</param-value>
</context-param>
<filter>
<filter-name>orbeon-xforms-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.OrbeonXFormsFilter</filter-class>
<init-param>
<param-name>oxf.xforms.renderer.context</param-name>
<param-value>/orbeon</param-value>
</init-param>
</filter>
<!-- This is necessary so that XForms engine resources can be served appropriately -->
<filter-mapping>
<filter-name>orbeon-xforms-filter</filter-name>
<url-pattern>/orbeon/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- Any web resource under /xforms-jsp is processed by the XForms engine -->
<filter-mapping>
<filter-name>orbeon-xforms-filter</filter-name>
<url-pattern>/page/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
</listener>
</web-app>
Thanks in advance
Sandro.
I'm not familiar with Orbeon XForms, so I'm not positive about what your problem is. But according to the above web.xml, the Orbeon filters are only applied to /orbeon/* and /page/* URLs, while the Rack filter gets applied to everything.
If the servlet approach works, why not stick with that?

How to Enable SSI (Server Side Includes) on Tomcat 7 at Ubuntu?

How can I enable SSI on Tomcat 7?.
I follow the directions however it doesn't work. I changed my main file's extension from html to shtml (not imported one) and unquoted that lines at web.xml:
<servlet>
<servlet-name>ssi</servlet-name>
<servlet-class>
org.apache.catalina.ssi.SSIServlet
</servlet-class>
<init-param>
<param-name>buffered</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>expires</param-name>
<param-value>666</param-value>
</init-param>
<init-param>
<param-name>isVirtualWebappRelative</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
What do do more, where is the wrong?
You also need to uncomment the SSI servlet mapping in web.xml
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
And create $CATALINA_HOME/conf/Catalina/localhost/<your app name>.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context privileged="true" >
</Context>
http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Introduction_to_SSL
You have to add the SSL configuration to the tomcat config this is detailed above and should help you out any questions after reading this let me know