In Oracle JDeveloper, open the project that contains your portlets. Edit a page or create a new page and choose Add Portlet.

Enhancing Java Portlets 7-7 Figure 7–3 Add Portlet Page

3. Click the magnifying glass icon next to the portlet and a preview window similar

to the one in Figure 7–4 displays. 7-8 Oracle Fusion Middleware Developers Guide for Oracle Portal Figure 7–4 Preview Window

7.2.2 Adding Personalization

In Section 7.2.1, Adding Show Modes you learned how to use the PDK Provider Framework to activate and render additional Show modes that were either not activated when creating the portlet with the wizard or not available through the wizard such as Link and Preview modes. This section describes the two Personalization modes Edit and Edit Defaults in more detail. When selected in the Java Portlet Wizard, Edit page and Edit Defaults page cause the generation of skeleton code for the two Personalization modes. The skeleton code enables you to access the personalization framework with a few lines of code rather than completely hand coding a personalization framework and a data store to hold the values. To add personalization to your portlet, you need to do the following: ■ Update the Edit page of your portlet to set and retrieve personalization changes. ■ Update the Edit Defaults page of your portlet to set and retrieve personalization changes. ■ Update the Show page of your portlets to use the personalization set by the user. The Edit and Edit Defaults modes allow portlet users to change a set of customizable parameters supported by the portlet, which typically drive the way the portlet is rendered in other modes. For a particular instance of a portlet on an Oracle Portal page, the personalizations made in the Edit and Edit Defaults modes apply only to that instance of the portlet. This is explained as follows: ■ Edit mode personalizations are specific to the individual user making the personalizations. This mode is activated by clicking the Personalize link on the portlet header in show mode. ■ Edit defaults mode personalizations apply to all users in the same locale who have not yet made specific personalizations to that portlet instance. This mode is generally only available to page designers, and can be activated by following the Edit icon on the page. When rendering Edit and Edit Defaults modes, a PortletRenderer can carry out either of the following tasks to support the personalization process: Enhancing Java Portlets 7-9 ■ Render the Edit Form : For each of the portlets customizable parameters, PortletRenderer uses a PortletPersonalizationManager to retrieve the current value and renders a control in an HTML form so the current value can be edited. ■ Handle Edit Form actions : When an OK or Apply button is clicked on the standard edit form header, PortletRenderer uses a PortletPersonalizationManager to store the personalized parameters submitted by the edit form and redirects the browser to the appropriate portal page. Therefore, the purpose of the PortletPersonalizationManager controller is to enable a PortletRenderer to store and retrieve the current values of customizable parameters that apply to a particular portlet instance and user. The PDK Framework uses the abstraction of a PersonalizationObject as a container for a set of personalized parameters and a PortletReference as the key under which a set of personalizations are stored. Thus, a PortletPersonalizationManager is simply a mechanism that allows the storage and retrieval of persisted PersonalizationObjects under a given PortletReference. A preference store is a mechanism for storing information like user preference data, portletprovider settings, or even portlet data, while using Oracle Portal. The information stored in the preference store is persistent in the sense that, even if you log out and log back in later, you can still access previously saved preferences. The preference store maintains the user preference information and invokes the user preferences whenever the user logs in again. PDK-Java provides the PrefStorePersonalizationManager, which uses a PreferenceStore implementation to persist personalized data. Currently, PDK-Java has two PreferenceStore implementations: DBPreferenceStore and FilePreferenceStore. The DBPreferenceStore persists data using a JDBC compatible relational database and FilePreferenceStore persists data using the file system. For more details of these implementations, refer to the Javadoc on OTN by clicking Java Doc API on the Portlet Development page available at http:www.oracle.comtechnologyproductsiasportalportlet_development_ 10g1014.html To add personalization functionality to your portlet you use PrefStorePersonalizationManager in conjunction with NameValuePersonalizationObject, that is, the default PersonalizationObject implementation. By default, the wizard generates a simple edit form for both the Edit and Edit Defaults modes to enable users to personalize the portlet title. This section describes how to update the existing code to enable portal users to personalize the portlet greeting.

7.2.2.1 Assumptions

To perform the tasks in this section, we are making the following assumptions: Note: PDK-Java provides the Preference Store MigrationUpgrade Utility to help migrate the preference store from a file system to a database and upgrade personalizations from earlier releases. This utility is described more fully on OTN. http:www.oracle.comtechnologyproductswebcenterindex.html