Creating Faces portlets and projects

Faces portlet projects share common characteristics with standard portlet and Faces projects, although there are some differences that you should be aware of.

Faces portlet projects are created using the New Portlet Project wizard. A default Faces portlet will be added in the process of creating the project. The wizard automatically generates Faces portlet configuration files, the directory structure that is required, and the necessary updates to the web.xml file.

The following types of resources defined by the Faces portlet APIs will be included in the project:

Resource type Files Target directory Notes
JARs All required Faces JAR files. WEB-INF/lib All Faces runtime JAR files are included in the portlet project WAR file.
Configuration files faces-config.xml WEB-INF Includes the variable resolver for portlet API objects
Deployment descriptors

  • web.xml

  • portlet.xml
WEB-INF

The following modifications are made to the standard web.xml file:

  • The servlet com.ibm.faces.webapp.JSResourceServlet is added.

  • servlet and servlet-mapping tags have ID attributes with string values, suffixed with a unique ID to prevent conflicts with other portlets.

    Note: Set context-param com.ibm.faces.portlet.USE_RENDER_PARAMETERS in your web.xml to "false". This is to enable the bridge to use Session instead of Render Parameters. While Websphere Portal has no limit on the size of Render Parameters, WAS has limits, therefore the bridge needs to use Session. For more details seeUsing Session

The following information is included in portlet.xml:

  • Portlet mode configuration is included.

  • Faces portlet-related init-param (JSR 168 portlet API and JSR 286) and config-param (IBM® portlet API) values are supplied.
The following sample configuration and deployment descriptor file snippets show representative tagging used within Faces portlet projects:

faces-config.xml

A lifecycle phase listener will be notified at the beginning and ending of processing for each standard phase of the request processing lifecycle. (For more information on lifecycle phase listener, search the terms PhaseListener and PhaseId at DeveloperWorks).

The following lifecycle section is added to Faces configuration files:

	<lifecycle>
		<phase-listener>com.ibm.faces.webapp.ValueResourcePhaseListener</phase-listener>
	</lifecycle>
VariableResolver sections are also added for each of the API types:

<!-- variable/property resolver registration [IBM portlet API] -->
	<application>
		<variable-resolver>com.ibm.faces.databind.SelectItemsVarResolver</variable-resolver>
		<variable-resolver>
		com.ibm.faces.application.WPPortletVariableResolver</variable-resolver>
		<property-resolver>com.ibm.faces.databind.SelectItemsPropResolver</property-resolver>
	</application>
or

<!-- variable/property resolver registration [JSR 168 portlet  or 286 portlet API] -->
	<application>
		<variable-resolver>com.ibm.faces.databind.SelectItemsVarResolver</variable-resolver>
		<variable-resolver>
		com.ibm.faces.portlet.PortletVariableResolver</variable-resolver>
		<property-resolver>com.ibm.faces.databind.SelectItemsPropResolver</property-resolver>
	</application>

portlet.xml

This is an example of IBM Faces portlet application defined in portlet.xml:

&lt;portlet-app-def>
	&lt;portlet-app uid="faces_portlet.FacesPortletPortlet.A_Unique_ID:1" major-version="1" minor-version="0">
		&lt;portlet-app-name>Faces Portlet application&lt;/portlet-app-name>
		&lt;portlet id="faces_portlet.FacesPortletPortlet" href="WEB-INF/web.xml#Servlet_A_Unique_ID:2" major-version="1" minor-version="0">
			&lt;portlet-name>Faces Portlet portlet&lt;/portlet-name>
			&lt;cache>
				&lt;expires>0&lt;/expires>
				&lt;shared>no&lt;/shared>
			&lt;/cache>
			&lt;allows>
				&lt;maximized />
				&lt;minimized />
			&lt;/allows>
			&lt;supports>
				&lt;markup name="html">
					&lt;view />
					&lt;edit />
				&lt;/markup>
			&lt;/supports>
		&lt;/portlet>
	&lt;/portlet-app>
	&lt;concrete-portlet-app uid="faces_portlet.FacesPortletPortlet.A_Unique_ID:3">
		&lt;portlet-app-name>Faces Portlet application&lt;/portlet-app-name>
		&lt;concrete-portlet href="#faces_portlet.FacesPortletPortlet">
			&lt;portlet-name>Faces Portlet portlet&lt;/portlet-name>
			&lt;default-locale>en&lt;/default-locale>
			&lt;language locale="en">
				&lt;title>Faces Portlet portlet&lt;/title>
				&lt;title-short>&lt;/title-short>
				&lt;description>&lt;/description>
				&lt;keywords>&lt;/keywords>
			&lt;/language>
			&lt;config-param>
				&lt;param-name>com.ibm.faces.portlet.page.view&lt;/param-name>
				&lt;param-value>/FacesPortletView.jsp&lt;/param-value>
			&lt;/config-param>
			&lt;config-param>
				&lt;param-name>com.ibm.faces.portlet.page.edit&lt;/param-name>
				&lt;param-value>/FacesPortletEdit.jsp&lt;/param-value>
			&lt;/config-param>
		&lt;/concrete-portlet>
	&lt;/concrete-portlet-app>
&lt;/portlet-app-def>  

 

Related concepts

JavaServer Faces portlet applications

 

Related tasks

Creating portlet JSP files

Adding and updating Faces portlet modes for existing IBM portlets

Adding and updating Faces portlet modes

Changing portlet modes using a Faces action

Changing a JSF portlet page without a JSF action

Accessing portlet API objects from Faces actions and components

Creating Faces portlet projects

 

Related reference

Using Session