Getting started with Liferay 6 and ICEfaces 2.0 - Part 2

This tutorial requires that you have read Part 1 of "Getting Started with Liferay 6 and ICEfaces 2.0".

So - time for a step by step "Hello World" tutorial with Liferay 6 and ICEfaces 2.0. I finally had the time to create a simple example. What we basically do is to combine an already existing icefaces 2.0 example of portletfaces with the liferay IDE. So if some of the content of the web.xml looks familiar to you, take a look here.

If you have installed the Liferay IDE, you can easily create a portlet. Give your portlet a fancy name, and now we have to transform it to be an ICEfaces 2.0 portlet.


JSF (and therefore ICEfaces) requires a config file called "faces-config.xml". Since JSF 2.0, a lot of the configuration stuff is obsolete and we just have to provide an empty faces-config.xml with the following in it:

 <?xml version="1.0" encoding="UTF-8"?>
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"


We need to tell our portlet, that it is now a "bridged" faces portlet, and no longer a standard MVC Portlet. We do so by adding the new portlet class and the new view id parameter:


Remove all other init-param parameters and the old portlet-class.


Big, big changes in the web.xml. Basically you can throw away your old one and replace it with these entries:




<servlet-name>Faces Servlet</servlet-name>

<servlet-name>Resource Servlet</servlet-name>
<servlet-name>Resource Servlet</servlet-name>

<web-resource-name>Facelet View XHTML</web-resource-name>



You need the following libs in your WEB-INF/lib directory :

  • commons-beanutils
  • commons-collections
  • commons-digester
  • commons-logging
  • icefaces-2.0.1
  • icefaces-compat-2.0.1
  • jboss-el.jar
  • jsf-api-2.1.1.jar
  • jsf-impl-2.1.0.jar
  • portletfaces-bridge-2.0.0.jar


Create a Managed Bean that will just return a "hello world" string:

package de.test.bean;

import javax.faces.bean.ManagedBean;

public class MyBean {
private String test = "Hello ICEfaces World !";

public String getTest() {
return test;

public void setTest(String test) {
this.test = test;

Next, create a file called index.xhtml in the root of your web application and reference your managed bean from it:

<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component" >
<h:head />
<h:body styleClass="example-icefaces-portlet">
<ice:outputText value="#{myBean.test}"/>

That should be all - your "Hello World" example with ICEfaces 2.0 and Liferay 6 is complete. 

If you liked this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.