Adding Event Logging Implementing Event Logging

8-44 Oracle Fusion Middleware Developers Guide for Oracle Portal wwlog_api.log p_domain = DOMAIN, p_subdomain = SUBDOMAIN, p_name = l_user, p_action = l_action, p_information = l_information, p_url = l_url, p_row_count = 0, p_elapsed_time= l_elapsed_time; ... 4. Optionally, if you want to see this portlet on a page and it is not already in the Portlet Repository, refer to the instructions in Section 8.3.2, Implementing the Provider Package for information on how to add it. 5. Once your portlet appears in the repository, you can add it to a page to test it. To add your portlet to a page, follow the instructions in Oracle Fusion Middleware Users Guide for Oracle Portal.

8.11 Writing Multilingual Portlets

Oracle Portal has a robust set of APIs for interacting with Oracle Portal multilingual storage facility. This storage facility provides a mechanism for storing and retrieving strings in different languages. These APIs abstract the native multilingual functionality and provide developers with a powerful storage mechanism for developing providers that support different language environments. Multilingual services are available through the wwnls_api package. These services include the following key features: ■ The multilingual APIs enable the provider to load several translations for the strings displayed in their portlets. Once the strings have been loaded, the provider can call the APIs to retrieve the strings from the multilingual table as needed. ■ Context APIs retrieve the users language and the appropriate translation for that language. The Context APIs determine the users language environment from the language setting in the browser. When a requested translation does not exist, the APIs return the base language translation. For example, assume that the providers register procedure loads US and French translations for the portlet title. When the portlet is rendered, the provider implementation retrieves the portlet title string from the table and displays the following results: ■ A request for a French string causes the portlet title to appear in French. ■ A request for a US string causes the portlet title to appear in US English. ■ A request for a Chinese string causes the portlet title to appear in US English because we did not load a translation for the Chinese language.

8.11.1 Using Multilingual Support

In general, you can set up multilingual support as follows: 1. Load your string definitions into the database using the string equivalents for each language you intend to use. For this purpose, call the wwnls_api.add_string or wwnls_api.set_string with an appropriate domain, subdomain, error message name, and error text combination. 2. Retrieve the strings you require with wwnls_api.get_string for the language that you desire. Creating PLSQL Portlets 8-45

8.11.2 Adding Multilingual Support

To add multilingual support, you need to perform the following tasks: ■ Section 8.11.2.1, Loading Language Strings ■ Section 8.11.2.2, Retrieving Language Strings

8.11.2.1 Loading Language Strings

Language strings can be loaded by a script that is part of the provider installation. This script calls add_string and set_string to create equivalent strings for different languages. Oracle Portal uniquely identifies language strings using a combination of domain, subdomain, and name. The domain and subdomain provide a way to categorize the strings. The domain and subdomain should be unique enough to reasonably preclude conflicts with other users of the APIs. ■ A domain is a particular area of the product. An example of a domain could be provider or page group. ■ A subdomain is a subsystem of the domain. For example, the subdomain could be the provider name for example, HelloProvider or subpage name for example, HelloPage. The services example, located in ..\pdkplsql\pdk\plsql\svcex in PDK-PLSQL pdkplsql.zip, illustrates how you can implement multilingual support. You can browse through this example as follows to see how to load strings for multilingual support: 1. Open the services_seed.sql file in an editor. 2. Notice the add_string call with the parameters for domain name, subdomain name, string name, language, and the actual string text. It returns the String ID for the language string. For setting equivalent strings in other languages, set_ string is called with the same parameters. set serveroutput on size 1000000 set define off declare l_string_id integer; l_person_id integer; l_group_id integer; begin ... -- strings for portlet record fields l_string_id := wwnls_api.add_string provider,services,ptldefname,us,DatabaseServicesPortlet; wwnls_api.set_string provider,services,ptldefname,d,DatenbankServicesPortlet-d; l_string_id := wwnls_api.add_string provider,services,ptldeftitle,us,Database Services Portlet; wwnls_api.set_string provider,services,ptldeftitle,d,Datenbank Services Portlet - d; l_string_id := wwnls_api.add_string provider,services,ptldefdesc,us,This is the database services portlet implemented in PLSQL. It displays 6 show modes.; wwnls_api.set_string provider,services,ptldefdesc,d,Dies ist das Datenbank Service Portlet, erstellt in PLSQL. Es stellt 6 Anzeigemodi dar. - d; l_string_id := wwnls_api.add_string 8-46 Oracle Fusion Middleware Developers Guide for Oracle Portal provider,services,ptldevtmmsg,us,Web Services Portlet Timed Out.; wwnls_api.set_string provider,services,ptldevtmmsg,d,Zeitüeberschreitung aufgetreten in Web Services Portlet. -d;

8.11.2.2 Retrieving Language Strings

The services example, located in ..\pdkplsql\pdk\plsql\svcex in PDK-PLSQL pdkplsql.zip, illustrates how you can implement multilingual support. You can browse through this example as follows to see how to retrieve strings for multilingual support: 1. Open the services_portlet.pkb file in an editor. 2. The domain and subdomain definitions for your language strings are provided with aliases in the constants part of your portlet definition. DOMAIN constant varchar230 := provider; SUBDOMAIN constant varchar232 := services; PORTLET_PATH constant varchar2256:= oracle.portal.pdk.servicesportlet; PREFNAME_STRING constant varchar230 := services_string; PREFNAME_TITLE constant varchar230 := services_title; 3. Find the get_portlet_info function. Notice the calls to wwnls_api.get_ string to populate the portlet title, name, and description. function get_portlet_info p_provider_id in integer ,p_language in varchar2 return wwpro_api_provider.portlet_record is l_portlet wwpro_api_provider.portlet_record; begin l_portlet.id := services_provider.SERVICES_PORTLET_ID; l_portlet.provider_id := p_provider_id; l_portlet.language := p_language; l_portlet.title := wwnls_api.get_string p_domain = DOMAIN ,p_sub_domain = SUBDOMAIN ,p_name = ptldeftitle ,p_language = p_language ; l_portlet.description := wwnls_api.get_string p_domain = DOMAIN ,p_sub_domain = SUBDOMAIN ,p_name = ptldefdesc ,p_language = p_language ; l_portlet.name := wwnls_api.get_string p_domain = DOMAIN ,p_sub_domain = SUBDOMAIN ,p_name = ptldefname ,p_language = p_language ; ...