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

Enhancing Java Portlets 7-25 renderer class=oracle.portal.provider.v2.render.RenderManager For more information on the syntax of provider.xml, refer to the provider Javadoc on OTN: http:www.oracle.comtechnologyproductsiasportalhtmljavadocx ml_tag_reference_v2.html 2. Import the following necessary classes into MyEventsPortlet: ■ oracle.portal.provider.v2.event.EventUtils ■ oracle.portal.utils.NameValue ■ oracle.portal.provider.v2.url.UrlUtils 3. In MyEventsPortlet, add a link that passes the parameter value to another portlet. As shown in the following sample code, you receive the same page parameter as the previous portlet, but in addition you create a link that passes an event as well: 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.ParameterDefinition import=oracle.portal.provider.v2.event.EventUtils import=oracle.portal.utils.NameValue import=oracle.portal.provider.v2.url.UrlUtils PortletRenderRequest pReq = PortletRenderRequest request.getAttributeHttpCommonConstants.PORTLET_RENDER_REQUEST; NameValue[] parameters = new NameValue[2]; parameters[0] = new NameValue EventUtils.eventNameMyEvent,; parameters[1] = new NameValueEventUtils.eventParameterMyParam,pReq.getParameter MyParam; span class=portletText1br a href== UrlUtils.constructLink pReq, pReq.getRenderContext.getEventURL, parameters , true, true The value of the stock is = pReq.getParameterMyParam a brbrspan 4. Add the portlet to a different page in the same page group than the previous portlet the Parameter Portlet. Expand the portlet and wire it to receive the same parameter as the previous portlet. My Parameter = Page Parameter MyParameter 5. Apply your changes on the Parameter tab and go to the Events tab. Expand the Event portlet and select the event. Select Go to Page and find the page to which Note: This sample code does not handle NULL values. When the portlet is initially added to the page, you may receive an error, but, after wiring the portlet to the page parameter, it should work fine. 7-26 Oracle Fusion Middleware Developers Guide for Oracle Portal you want to pass the event. Choose the page where the Parameter portlet is located. Configure this portlet to pass an event as the page parameter MyParameter as shown in Figure 7–7 . MyParameter = Event Output MyParameter Figure 7–7 Portlet Events in the Edit Page

6. Click OK to view the page. Your Event portlet should have a link that displays the

value received from the page Figure 7–8 . Figure 7–8 My Event Portlet Before Parameter Change

7. You can append a parameter value to the URL and the portlet displays the value

in the link. MyParameter=20

8. When you click the link, that value is passed to the Parameter portlet on its page

Figure 7–9 . Enhancing Java Portlets 7-27 Figure 7–9 My Event Portlet After Parameter Change

7.2.4 Using JNDI Variables

When writing Java portlets, you may set deployment specific properties through the JNDI service such that their values may be retrieved from your provider code. In this way, you can specify any property in a provider deployment and then easily access it anywhere in your provider code. PDK-Java provides utilities to enable the retrieval of both provider and non-provider JNDI variables within a J2EE container. To use JNDI variables, you need to perform the following tasks: ■ Section 7.2.4.1, Declaring JNDI Variables ■ Section 7.2.4.2, Setting JNDI Variable Values ■ Section 7.2.4.3, Retrieving JNDI Variables

7.2.4.1 Declaring JNDI Variables

You declare JNDI variables in the web.xml file for your provider. The format for declaring a JNDI variable is as follows: env-entry env-entry-namevariableNameenv-entry-name env-entry-typevariableTypeenv-entry-type env-entry-valuevariableValueenv-entry-value env-entry The env-entry-name element contains the name by which you want identify the variable. env-entry-type contains the fully qualified Java type of the variable. env-entry-value contains the variables default value.

7.2.4.1.1 Variable Types In the env-entry-type element, you should supply the

fully-qualified Java type of the variable, which will be expected by your Java code. The Java types you may use in your JNDI variables are as follows: ■ java.lang.Boolean ■ java.lang.String ■ java.lang.Integer ■ java.lang.Double ■ java.lang.Float The J2EE container uses these type declarations to automatically construct an object of the specified type and gives it the specified value when you retrieve that variable in your code.

7.2.4.1.2 Variable Naming Conventions The PDK-Java defines a number of environment

variables that can be set at the individual provider service level or at the Web application level. To avoid naming conflicts between different provider services or different application components packaged in the same Web application, we recommend you devise some naming convention. 7-28 Oracle Fusion Middleware Developers Guide for Oracle Portal For example: ■ Provider service specific names should be of the form: {company}{component name}{provider name}{variable name} ■ Shared names should be of the form: {company}{component name}{provider name}global where: ■ {company} is the name of the company owning the application. ■ {component name} is the name of the application or component with which the provider is associated. ■ {provider name} is the service name of the provider. ■ {variable name} is the name of the variable itself. As you can see, these naming conventions are similar to those used for Java packages. This approach minimizes the chance of name collisions between applications or application components. PDK-Java provides utilities that allow you to retrieve variables in this form without hard coding the service name of the provider into your servlets or JSPs. The service name need only be defined in the providers WAR file. Refer to Section 7.2.4.3, Retrieving JNDI Variables for more information on retrieving JNDI variables.

7.2.4.1.3 Examples The following examples illustrate provider variable names:

oracleportalmyProvidermyDeploymentProperty oracleportalmyprovidermyPropertiesmyProperty The following example illustrates non-provider variable names: oracleportalmyOtherProperty

7.2.4.2 Setting JNDI Variable Values

In your provider deployment, you may want to set a new value for some or all of your JNDI variables. You can perform this task by setting the values manually in a Oracle WebLogic Server deployment plan as follows:

1. Go to the provider deployment in the Oracle WebLogic Administration Console,

and create a new Deployment Plan if one hasnt been set against it.

2. Edit the Deployment Plan XML file. For each deployment property you want to

set, add the following variable definition directly under the deployment-plan tag: variable-definition variable namejndi_var_defname valuefalsevalue variable variable-definition Note: If you use the EnvLookup method, you must use oracleportalproviderserviceproperty. You cannot substitute your own company name or component in this case.