Preference Information Within the XML Provider Definition

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. Enhancing Java Portlets 7-15 Figure 7–5 Parameter Portlet If you have a portlet, such as the Simple Parameter Form included with OmniPortlet, that can pass parameters, you can map parameters from that portlet to your Java portlet using the Events tab. If you now take a look at the code and tags generated by the wizard, you see that very little code was needed to enable parameters in the Java portlet. Review provider.xml. Note that the wizard added one tag group called inputParameter, which includes the name of the parameter for which the portlet listens. inputParameter class=oracle.portal.provider.v2.DefaultParameterDefinition nameMyParamname displayNameMy Portlet ParameterdisplayName inputParameter For more information on the syntax of provider.xml, refer to the provider Javadoc on OTN: http:www.oracle.comtechnologyproductsiasportalhtmljavadocxml_tag_ reference_v2.html The wizard also generated code in the JSP for your Show page that receives this parameter, and displays the parameter name and its value. ParameterDefinition params[] = pReq.GetPortletDefinition.getInputParameters; pThis portlets input parameters are ...p table align=left width=50trtdspan class=PortletHeading1Value spantdtr String name = null; String value = null; String[] values = null; for int i = 0; i params.length; i++ { name = params[i].getName; values = pReq.getParameterValuesname; if values = null { StringBuffer temp = new StringBuffer; for int j = 0; j params.length; j++ { temp.appendvalues[j]; if j + 1 = values.length { temp.append, ; }