Setting up an Icefaces facelet project from scratch.

Icefaces is a rich extension to Java Server Faces. One of the problems in getting an icefaces application up and running is the inital setup. In this tutorial I’ll walk through how to build a basic Icefaces application (Using facelets).

I love IDEs like intellij and Eclipse. They make setting up projects easy. But I have found that setting up my projects from scratch gives me the flexibility I need, and also makes integrating with an automated build system easier.

Project layout

/simple-ice-facelet/ Project Root
/simple-ice-facelet/lib/ Required Jar files to run the web app
/simple-ice-facelet/src Java source
/simple-ice-faceletd/web Web Contents

Required Jars found in icefaces/lib

  • backport-util-concurrent.jar
  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-fileupload.jar
  • commons-logging.jar
  • commons-logging-api.jar
  • el-api.jar
  • icefaces.jar
  • icefaces-comps.jar
  • icefaces-facelets.jar
  • xercesImpl.jar
  • xml-apis.jar

Bare bones app config

/simple-ice-facelet/web/WEB-INF/faces-config.xml


<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/JSF/Configuration">

<application>
<view-handler>
com.icesoft.faces.facelets.D2DFaceletViewHandler
</view-handler>
</application>
</faces-config>

/simple-ice-facelet/web/WEB-INF/web.xml


<!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>

<display-name>Simple ICEFaces App</display-name>

<description>
Just getting started
</description>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</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.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
<param-value>true</param-value>
</context-param>

<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>

<servlet>
<servlet-name>icefaces</servlet-name>
<servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>

<servlet>
<servlet-name>block</servlet-name>
<servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>icefaces</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>icefaces</servlet-name>
<url-pattern>*.iface</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>block</servlet-name>
<url-pattern>/block/*</url-pattern>
</servlet-mapping>

</web-app>

And now for a basic facelet page.

/simple-ice-facelet/web/test.xhtml


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<head>
<title>Testing</title>

</head>
<body>
<ice:form>
<ice:panelGroup draggable=”true” style=”width:200px;border:1px solid black;”>
<ice:outputText value=”If you can drag me then it works!”/>
</ice:panelGroup>
</ice:form>
</body>
</html>

And Finally the build file. You will need to have TOMCAT_HOME defined.

/simple-ice-facelet/build.xml


<project name="simple-ice-facelet" default="war" basedir=".">
<description>
Simple Icefaces Facelet app
</description>

<property name=”src” location=”src”/>
<property name=”build” location=”web/WEB-INF/classes”/>
<property name=”icefaces-lib” location=”lib/”/>
<path id=”base.path”>
<pathelement path=”${classpath}”/>
<fileset dir=”${icefaces-lib}”>
<include name=”**/*.jar”/>
</fileset>

</path>
<property environment=”env”/>

<target name=”compile”
description=”compile the source ” >
<mkdir dir=”${build}”/>
<javac srcdir=”${src}” destdir=”${build}”>
<classpath refid=”base.path”/>
</javac>
<copy todir=”${build}”>
<fileset dir=”${src}”>
<include name=”**/*.xml”/>
<include name=”**/*.tld”/>
<include name=”**/*.js”/>
</fileset>
</copy>
</target>

<target name=”war” depends=”compile”
description=”generate the distribution” >
<war destfile=”facelet.war” webxml=”web/WEB-INF/web.xml”>
<fileset dir=”web”/>
<lib dir=”lib”>
</lib>
</war>
</target>

<target name=”clean”
description=”clean up” >
<delete dir=”${build}”/>
</target>

<target name=”copy.war” depends=”clean, war”>
<copy file=”facelet.war” todir=”${env.TOMCAT_HOME}/webapps”/>
</target>
</project>

Run the copy war then open http://localhost:8080/facelet/test.iface If you can drag the div around the screen then this tutorial has been a success!

Need help developing your ICEFaces application? I can provide ICEFaces consulting. Contact me at rob.mayhew@gmail.com for more information.

Posted in Icefaces | 4 Comments

cl1p.com

I’ve setup cl1p.com to run a plain version of cl1p.net. It’s text only, no files or pictures. But it is fast.

It’s my first project hosted on the google app engine.

Check it out http://cl1p.com

Posted in Uncategorized | 2 Comments

cl1p back up

cl1p is back up and the database is restored.

Posted in Uncategorized | Leave a comment

cl1p is down

The server where cl1p.net is hosted has experienced a hardware failure of some sort. I’m looking into it now.

Posted in Uncategorized | Leave a comment

New version of cl1p released!

A few months ago I sent out a survey asking users what they wanted in cl1p. You told me that you wanted pictures, bigger files, and a better user interface.

The latest version of cl1p has all of these features and more!

A new user interface has been created with a simple icon driven menu.

Bigger file uploads. Now you can upload 30MB files (200MB for paid cl1ps)

Pictures. Now upload and share 2 pictures per cl1p, (20 for paid cl1ps)

Clickable links. Stop copying and pasting links into the browser. Now, click the LINK button and all of the links on your cl1p are clickable!

….plus many other improved features!

As always, your feedback drives development. If there is a feature you need please let me know. Post a message on the cl1p forum. http://cl1p.robmayhew.com.

Thanks for using cl1p!

Rob Mayhew

Posted in cl1p | Leave a comment