the last few days I had some problems setting up the web part for my upcoming application.
As I know that some of you guys stumbled upon my blog because you were looking for ICE Faces 1.8.x integration, I thought it would be useful to post my 'set up configuration'.
I am using Netbeans 6.7.1 with Maven 2.2.0 and IceFaces 1.8.1 and glassfish V3 prelude.
Let's start with the faces-config.xml, where you have to add the ICEfaces specific view handler
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<application>
<view-handler>
com.icesoft.faces.facelets.D2DFaceletViewHandler
</view-handler>
</application>
</faces-config>
(this page helps you add xml code to your blog: http://centricle.com/tools/html-entities/
The next important configuration file is the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>ICEfaces 1.8.1</display-name>
<description>web.xml for a icefaces 1.8.1 application</description>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Persistent Faces Servlet</servlet-name>
<servlet-class>
com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Blocking Servlet</servlet-name>
<servlet-class>
com.icesoft.faces.webapp.xmlhttp.BlockingServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.iface</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Blocking Servlet</servlet-name>
<url-pattern>/block/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>justatest.iface</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<!-- Listener implementation to handle web application lifecycle
events -->
<listener>
<listener-class>
com.sun.faces.application.WebappLifecycleListener
</listener-class>
</listener>
<listener>
<listener-class>
com.icesoft.faces.util.event.servlet.ContextEventRepeater
</listener-class>
</listener>
</web-app>
I use xhtml files for developing the user interface. If I enter the URL http://...../justatest.iface , the corresponding xhtml file will be rendered and send back to the client. (see the highlighted parts)
Last but not least the maven pom.file for all the required libraries
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>yourGroupID</groupId>
<artifactId>YourApplicationID</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>YourApplicationName</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-facelets</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-comps</artifactId>
<version>1.8.1</version>
<exclusions>
<exclusion>
<artifactId>jxl</artifactId>
<groupId>net.sourceforge.jexcelapi</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<finalName>YourApplicationName</finalName>
</build>
</project>
So, have fun developing with ICEFaces and let me know if this configuration was helpful for you.
Greetings Daniel
Hi again,
ReplyDeletethere was one missing element in the web.xml. I had the problem that no action button was working. Not working was like not even a http post was sent. The problem was that icefaces couldn't access the javascript files icefaces-d2d.js and ice-extras.js. After adding web.xml mapping for xmlhttp it finally worked/works
I think el-api needs to be excluded as well. I could not get a simple HelloWorld with ICEfaces and facelets to deploy correctly until I modified the pom.xml as follows...
ReplyDelete<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>1.8.1</version>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-facelets</artifactId>
<version>1.8.1</version>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-comps</artifactId>
<version>1.8.1</version>
<exclusions>
<exclusion>
<artifactId>jxl</artifactId>
<groupId>net.sourceforge.jexcelapi</groupId>
</exclusion>
</exclusions>
</dependency>
Maven is an excellent tool, much appreciated for its ability to help harmonize and standardize build practices within an organization. Maven offers powerful features such as standard build lifecycles and directory structures, easy code quality metrics reporting, and sophisticated transitive dependency management, just to name a few.
ReplyDeletehi i ma from peru.. Can you send me this complete example... I dont understand very well this "I use xhtml files for developing the user interface. If I enter the URL http://...../justatest.iface , the corresponding xhtml file will be rendered and send back to the client. (see the highlighted parts)" well this is my email james.po.72@gmail.com
ReplyDelete