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, or the New Portlet Project (JSR 168) wizard, depending on the portlet API that you want to base the project on. 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.
Resource type | Files | Target directory | Notes |
---|---|---|---|
JARs | All required Faces *.jar files. | WEB-INF/lib | |
Configuration files | faces-config.xml | WEB-INF | Includes the following:
|
Deployment descriptors |
|
WEB-INF | The following modifications are made to the standard web.xml file:
The following information is included in portlet.xml:
|
<lifecycle> <phase-listener>com.ibm.faces.webapp.ValueResourcePhaseListener</phase-listener> </lifecycle>The FactoryFinder API provides information about factories, as well as links to specific factories. The following factory finder section is added to Faces configuration files for an IBM® API portlet:
<factory> <faces-context-factory>com.ibm.faces.context.WPPortletFacesContextFactoryImpl</faces-context-factory> </factory>For a JSR 168 API portlet, the factory is defined as follows:
<factory> <faces-context-factory>com.ibm.faces.context.PortletFacesContextFactoryImpl</faces-context-factory> </factory>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 API] --> <application> <variable-resolver>com.ibm.faces.databind.SelectItemsVarResolver</variable-resolver> <variable-resolver> com.ibm.faces.application.PortletVariableResolver</variable-resolver> <property-resolver>com.ibm.faces.databind.SelectItemsPropResolver</property-resolver> </application>
<servlet id="Faces_Unique_Servlet_Name"> <servlet-name>faces_portlet.FacesPortletPortlet</servlet-name> <display-name>faces_portlet.FacesPortletPortlet</display-name> <servlet-class>com.ibm.faces.webapp.WPFacesGenericPortlet</servlet-class> </servlet>This is an example of servlet-mapping for a Faces portlet servlet.
<servlet-mapping> <servlet-name>faces_portlet.FacesPortletPortlet</servlet-name> <url-pattern>/faces_portlet.FacesPortletPortlet/*</url-pattern> </servlet-mapping>
<portlet-app-def> <portlet-app uid="faces_portlet.FacesPortletPortlet.A_Unique_ID:1" major-version="1" minor-version="0"> <portlet-app-name>Faces Portlet application</portlet-app-name> <portlet id="faces_portlet.FacesPortletPortlet" href="WEB-INF/web.xml#Servlet_A_Unique_ID:2" major-version="1" minor-version="0"> <portlet-name>Faces Portlet portlet</portlet-name> <cache> <expires>0</expires> <shared>no</shared> </cache> <allows> <maximized /> <minimized /> </allows> <supports> <markup name="html"> <view /> <edit /> </markup> </supports> </portlet> </portlet-app> <concrete-portlet-app uid="faces_portlet.FacesPortletPortlet.A_Unique_ID:3"> <portlet-app-name>Faces Portlet application</portlet-app-name> <concrete-portlet href="#faces_portlet.FacesPortletPortlet"> <portlet-name>Faces Portlet portlet</portlet-name> <default-locale>en</default-locale> <language locale="en"> <title>Faces Portlet portlet</title> <title-short></title-short> <description></description> <keywords></keywords> </language> <config-param> <param-name>com.ibm.faces.portlet.page.view</param-name> <param-value>/FacesPortletView.jsp</param-value> </config-param> <config-param> <param-name>com.ibm.faces.portlet.page.edit</param-name> <param-value>/FacesPortletEdit.jsp</param-value> </config-param> </concrete-portlet> </concrete-portlet-app> </portlet-app-def>