Search This Blog

2009-08-28

Netbeans 6.7.1, Maven WebApp with IceFaces 1.8.1 - a setup guide

Hi guys,
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

2009-08-11

Which web application framework do you recommend?

Hi guys,
it has been quite a long time since I published my last post. Sorry for that. Now that summer has finally arrived in Germany, it seems that every day there is an event after work. So I haven't found much time for developing. But one of my goals for the next few weeks is to release the first version of a Basketball Software, which a friend of mine asked me to do develop. I am not happy with the progress I am making, but my real life projects have a higher priority.
Considering this Basketball App, I started setting up the entity model, set up the workspace including a hudson environment (I love hudson, even for a one man project) and wrote the first session beans. I chose EJB3 for the backend part. However, what I haven't decided yet is the front-end part. I have done some projects using different JSF implementations, but I am thinking about whether I should try out something else. Can anyone of you recommend me something?
What about JavaFX? How good is the integration with JavaEE?
What about Wicket, GWT or Google Gears?
I'd love to do an evaluation for all of the implementations. Maybe I ll find some time to create one feature (like the createNewPlayer userInterface) with each of the frameworks. But if anyone out there has already done this evaluation, I would be very grateful.
So..as soon as I reached a certain progress level, I will write something about the upcoming application.

Have a great day..
Daniel