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

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 7-10 Oracle Fusion Middleware Developers Guide for Oracle Portal 1. You have followed through and understood the following sections: ■ Section 6.5, Building Oracle PDK-Java Portlets with Oracle JDeveloper ■ Section 7.2.1, Adding Show Modes

2. You built a portlet using the wizard, with Edit page and Edit Defaults page

selected, and successfully added it to a page.

7.2.2.2 Implementing Personalization for Edit and Edit Defaults Pages

The Edit page of your portlet is called when a user personalizes the portlet. By default, the JSP generated by the wizard includes all of the required code to provide personalization of the portlet title. You just need to insert a few lines of code into the Edit page for additional personalization.

7.2.2.2.1 Reviewing the Generated Code The wizard creates the following code for you by

default: page contentType=texthtml; charset=windows-1252 import=oracle.portal.provider.v2.render.PortletRenderRequest import=oracle.portal.provider.v2.http.HttpCommonConstants import=oracle.portal.provider.v2.personalize.NameValuePersonalizationObject import=oracle.portal.provider.v2.render.PortletRendererUtil PortletRenderRequest pReq = PortletRenderRequest request.getAttributeHttpCommonConstants.PORTLET_RENDER_REQUEST; PHello =pReq.getUser.getName .P PThis is the biEditib render modeP -- This page both displays the personalization form and processes it,. Display the form if there is no action parameter, process it otherwise -- String actionParam = PortletRendererUtil.getEditFormParameterpReq; String action = request.getParameteractionParam; String title = request.getParametermy2portlet_title; NameValuePersonalizationObject data = NameValuePersonalizationObject PortletRendererUtil.getEditDatapReq; Cancel automatically redirects to the page, so will only receive OK or APPLY if action =null { data.setPortletTitletitle; PortletRendererUtil.submitEditDatapReq, data; return; } Otherwise just render the form. title = data.getPortletTitle; table border=0 td width=20 p align=rightTitle:p td td width=80