Using Portlet Preferences with JSF

JSF portlet developers often must enable the end-user to personalize portlets in some way. To meet this requirement, the Portlet 2.0 specification lets you define portlet preferences for each portlet. Preference names and default values are defined in the WEB-INF/portlet.xml descriptor. Portal end-users start out interacting with the portlet user interface in portlet VIEW mode, but switch to portlet EDIT mode in order to select custom preference values.

Here’s an example portlet preference descriptor that sets a date pattern:


Additionally, Portlet 2.0 lets you specify support for EDIT mode in the WEB-INF/portlet.xml descriptor file. You can add EDIT mode by specifying the element <portlet-mode>edit</portlet-mode> in your portlet.xml file’s <supports> element. The following example snippet specifies EDIT mode in addition to the VIEW and HELP modes.


Although support for portlet EDIT mode has been specified, the portlet container doesn’t necessarily know which JSF view should be rendered when the user enters portlet EDIT mode. JSF portlet developers must specify the facelet view in the WEB-INF/portlet.xml descriptor that should be displayed for each supported portlet mode. The following example snippet specifies a facelet file /preferences.xhtml as the view, by mapping it to the javax.portlet.faces.defaultViewId.edit init parameter.


Terrific! You’re now familiar with specifying and using portlet preferences in your JSF portlet.

Localizing JSF Portlets

Liferay Faces Alloy UI Components

Liferay Faces Bridge UI Components

Understanding Liferay Faces Bridge

« Specifying the portlet.xml File for Your JSF PortletGiving Feedback to Users with Validation Messages »
Was this article helpful?
0 out of 0 found this helpful