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:
The following sample configuration and deployment descriptor file snippets show representative tagging used within Faces portlet projects:
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.
- 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:
<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>
Related concepts
JavaServer Faces portlet applications
Related tasks
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