Portlet DevelopmentPortlet support in ICEfaces is now provided by the PortletFaces Bridge, an implementation of the JSR 329: Portlet 2.0 Bridge for JavaServer Faces. The portlet bridge specification technically applies to JSF 1.2 but the PortletFaces version been adapted to support JSF 2. The PortletFaces Bridge is tested and shipped with the ICEfaces 2 distribution and can be used to develop portlet applications with ICEfaces.
ExamplesThe following sample portlets are included in the ICEfaces distribution. The examples are useful for getting a quick start on how to build a portlet using ICEfaces and the PortletFaces Bridge. This includes what the markup should look like, what files need to be included, and how they should be configured. For each portlet example, there is a corresponding non-portlet example. Looking under the [icefaces.dir]/samples, you'll find: showcase/showcase showcase/showcase-portlet core/chat core/chat-portlet Each portlet example is built by using the content from the non-portlet sample and adding in the portlet-specific files required. Details for each sample are provide below. ChatThe Chat example is a demonstration portlet that uses only stock JSF components and ICEpush. You can drop multiple instances on a single portal page and chat between the instances and between different browsers. The sample code is located under: [icefaces.install.dir]/icefaces/samples/core/chat-portlet To build a portlet .war file for Liferay 6 running on Tomcat 6.0, you execute the following ant command from the chat-portlet directory: [icefaces.install.dir]/icefaces/samples/core/chat-portlet > ant clean liferay6.servlet-profile The result is a portlet-compatible version of Chat located under: [icefaces.install.dir]/samples/core/chat-portlet/build/dist/chat-portlet.war This .war file can be deployed directly to the Liferay deploy directory. Once deployed, it will show up in the list of available portlets under the ICEfaces -> ICEpush category. ShowcaseThe Showcase portlets are examples based on the ICEfaces Showcase example configured to run in a portal. It uses the same markup and code as the non-portlet demo, but with each component example delivered as an individual portlet. The sample is located under: [icefaces.install.dir]/icefaces/samples/showcase/showcase-portlet To build a portlet .war file for Liferay 6 running on Tomcat 6.0, you execute the following ant command from the chat directory: [icefaces.install.dir]/icefaces/samples/showcase/showcase-portlet > ant clean liferay6.servlet-profile The result is a portlet compatible version of Component Showcase located under: [icefaces.install.dir]/icefaces/samples/showcase/showcase-portlet/build/dist/showcase-portlet.war This .war file can be deployed directly to the Liferay deploy directory. Once deployed, it will show up in the list of available portlets under the ICEfaces3/Suite/ACE category. Building Your Own Portletsportlet.xmlICEfaces makes use of the PortletFaces Bridge to handle the mapping of the portlet lifecycle onto the JSF lifecycle. This has many advantages like enabling proper resource handling and cleaner integration with the portal container. To define your portlet, take a look at the portlet definition of the chat portlet example: <portlet> <portlet-name>chat-ice2-portlet</portlet-name> <display-name>Chat</display-name> <portlet-class>org.portletfaces.bridge.GenericFacesPortlet</portlet-class> <init-param> <name>javax.portlet.faces.defaultViewId.view</name> <value>/chat.xhtml</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <portlet-info> <title>ICEfaces 2 Chat</title> <short-title>ICEfaces 2 Chat</short-title> <keywords>icefaces portlet chat icepush</keywords> </portlet-info> </portlet> The important parts are:
web.xmlTo prevent the processing of portlet resource URLs to avoid caching of things like bridge.js, the following parameter should be set to false. <context-param> <param-name>org.icefaces.uniqueResourceURLs</param-name> <param-value>false</param-value> </context-param> Library DependenciesThe ICEfaces distribution includes a tested release version of the PortletFaces Bridge and is located in: [icefaces.install.dir]/icefaces/lib/portlets
|
Portlet Development
© Copyright 2012 ICEsoft Technologies Inc.