Modifying the Generated Code The JSP contains an input field for the portlet

Enhancing Java Portlets 7-13 preferenceStore class=oracle.portal.provider.v2.preference.FilePreferenceStore nameprefStore1name useHashingtrueuseHashing preferenceStore At the portlet level, tags are added to use PrefStorePersonalizationManager as the personalizationManager class and NameValuePersonalizationObject as the data class: personalizationManager class=oracle.portal.provider.v2.personalize. PrefStorePersonalizationManager dataClassoracle.portal.provider.v2.NewValuePersonalizationObjectdataClass personalizationManager You need not make any changes or updates to the XML Provider Definition if you choose to continue to use the FilePreferenceStore class. However, if you have a global environment for Oracle Portal for example, you are running in a load balanced, multi-node cluster of Oracle Containers for Java EE instances or would prefer to store preferences in the database, you can change the class from FilePreferenceStore to DBPreferenceStore. For more information on using DBPreferenceStore, refer to the Oracle Fusion Middleware Administrators Guide for Oracle Portal. For more information on the syntax of provider.xml, refer to the provider Javadoc on OTN: http:www.oracle.comtechnologyproductsiasportalhtmljavadocxml_tag_ reference_v2.html

7.2.2.5 Viewing the Portlet

To view the personalization changes you made in the preceding sections, you need to deploy the portlet to your application server or Oracle Containers for Java EE and refresh the page containing your portlet. For more information on deploying your portlet, refer to Section 6.5.4, Deploying Your Oracle PDK-Java Portlet to an Application Server . You should now see that the portlet contains a null greeting. Click Personalize in the portlet title bar and update the greeting. When you return to the page, you should see your changes. You can also test Edit Defaults by clicking Edit on the page and then clicking the Edit Defaults icon. Since you have already modified the portlet, the changes will not appear to you in Shared Screen mode unless you view the page as a public user or a different user.

7.2.3 Passing Parameters and Submitting Events

Oracle Portal and the PDK provide page parameters, public and private portlet parameters, and events to enable portlet developers to easily write reusable, complex portlets. The Portlet Wizard in Oracle JDeveloper creates portlets that are already set up to use parameters and events. This feature enables you to focus solely on adding business logic to your portlets and does not require any changes to provider.xml. For an overview of parameters and events, refer to the following: ■ Section 2.12, Public Portlet Parameters Support ■ Section 2.13, Private Portlet Parameter Support ■ Section 2.14, Event Support 7-14 Oracle Fusion Middleware Developers Guide for Oracle Portal

7.2.3.1 Assumptions

To perform the tasks in this section, the following assumptions are made:

1. You have followed through and understood

Section 6.5, Building Oracle PDK-Java Portlets with Oracle JDeveloper .

2. You built a portlet using the wizard and successfully added it to a page.

7.2.3.2 Adding Public Parameters

Using the wizard in Section 6.5, Building Oracle PDK-Java Portlets with Oracle JDeveloper , you built a basic portlet and specified a parameter called MyParam. If you did not create a parameter, you can create a new portlet now by right clicking on provider.xml in the Applications - Navigator of Oracle JDeveloper, selecting Add Portlet , and following the steps in Section 6.5, Building Oracle PDK-Java Portlets with Oracle JDeveloper . By default, the wizard creates a portlet to which you can easily map page parameters without updating any code or files. In this section, you will use the default parameter created for you by the wizard. To use the default parameter, you need only register the provider and add the portlet to a page. After that, you perform the following tasks: ■ Create a page parameter. ■ Wire the page parameter to your Java portlet. ■ Enter parameter values in the URL or another portlet that passes this page parameter. To add parameters to your portlet:

1. Go to the Parameter tab of the page properties. Note that parameters should be

enabled by default, but, if not, you must enable them before proceeding. 2. Create a page parameter called MyParameter with a default value of My Default Value. 3. Expand your Java portlet and map the page parameter you just created to the portlet parameter. The portlets parameter should map to the page parameter called MyParameter. 4. Go back to the page. Notice that, in the portlet, a value of My Default Value appears. 5. View the page and enter the parameter and a value at the end of the URL: MyParameter=This20portlet20works Figure 7–5 shows an example of a parameter portlet. Note: Each portlet is limited to 4K of data. The lengths of parameter and event names, display names, and descriptions all contribute toward this 4K limit. Hence, you should not use an excessive number of parameters and events for each portlet, or give them lengthy names and descriptions.