Liferay & ICEFaces: I love this combination

Nov 09, 2011
Diego Vergara

This is my third post in the liferay series, this time I'm going to talk about ICEFaces portlets with IPC - Inter-Portlet Communication - that refers to the ability by which portlets can communicate with each other in a spec compliant way..But this communication occurs inside the same war, when you want to communicate portlets in different wars this is called "remoting". You can find answers to this here

Implementing an ICEFaces or any JSF portlet with IPC in Liferay was not that easy, until Neil Griffin posted this webinar where he describes the way to implement IPC with ICEFaces.

ICEFaces is a fascinating topic and you can get a lot of info in ICEFaces site and a quick introduction of its features in a previous post. I have found, you can also find a great review of ICEFaces in this presentation done by Jorge Tapia.

Using ICEFaces + AJAX + IPC + Liferay it's a great combination, but to accomplish this you must have a necessary class which emulates the session scope accross multiple portlets (you can find this class in the source code of Neil's sample).

/**
* @author Neil Griffin
**/
public class PortletSessionUtil {
...
...

public static Object getSharedSessionAttribute(String key) {
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletSession portletSession = (PortletSession)facesContext.getExternalContext().getSession(false);

return portletSession.getAttribute(key, PortletSession.APPLICATION_SCOPE);
}
public static void setSharedSessionAttribute(String key, Object value) {
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletSession portletSession = (PortletSession)facesContext.getExternalContext().getSession(false);
portletSession.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);
}
}

After this you can start coding your app with multiple portlets. Why multiple porltets? Becuase it's possible that the necessary info is to long to be displayed in a graceful manner in a single portlet or because the extra functionality for each section of the app needs a large panel or because we're interested in giving the user the ability to customize their environment by placing the portlets in the way they want.

agile-tool