Adding Multilingual Support Writing Multilingual Portlets

Creating PLSQL Portlets 8-47 4. Browse the rest of the file to examine other usage examples of wwnls_api.get_ string, which is used in several other places in services_portlet.pkb. 5. 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. 6. 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.12 Enhancing Portlets for Mobile Devices

This section explains how to go about enhancing a portlet with PDK-PLSQL for a mobile device. Before proceeding with this section, you should familiarize yourself with the guidelines for building mobile-enabled portlets, Section 8.1.3, Guidelines for Mobile Portlets , and the methods of building portlets with PDK-PLSQL, Section 8.2, Building PLSQL Portlets with the PLSQL Generator and Section 8.3, Building PLSQL Portlets Manually . To properly build a portlet for a mobile device, do the following: 1. Set the portlet record attributes to support mobile output. Requests arriving from mobile devices through the mobile gateway need to be answered with OracleAS Wireless XML using the textvnd.oracle.mobilexml content type in the header. A mobile-enabled portlet must specify that it can handle these types of requests and produce the mobile content accordingly. Table 8–6 lists the portlet record attributes pertinent to mobile portlets and explains how you should specify them. Table 8–6 Portlet Record Attributes Attribute Description accept_content_type Specify a comma-delimited list of the content types that the portlet produces. If the portlet can produce both HTML and OracleAS Wireless XML, the string would be: texthtml, textvnd.oracle.mobilexml If the portlet can produce only OracleAS Wireless XML, the string would be: textvnd.oracle.mobilexml mobile_only Indicate whether the portlet is available only to mobile pages. TRUE declares the portlet as mobile only, and it will not appear in the Add Portlets page for a standard page. FALSE declares the portlet as mobile and standard, and it will appear in the Add Portlets page for both standard and mobile pages. If the portlet only produces OracleAS Wireless XML and you set this flag to FALSE, the OracleAS Wireless XML is automatically transformed into HTML for desktop devices such as a normal PC Web browser. This functionality enables you to develop portlets that output only OracleAS Wireless XML but can be viewed on standard pages for desktop access as well as for mobile access. short_title Enter a shorter version of the portlet title. This title is used on mobile devices because it is more likely to fit the smaller screen. If you do not set a short title, then the portlet title is used instead. 8-48 Oracle Fusion Middleware Developers Guide for Oracle Portal 2. If the portlet can produce both HTML and OracleAS Wireless XML, then, during execution, it must determine whether the request is for a mobile or a desktop device. If it is a desktop request, then the portlet must product HTML output. If it is a mobile request, then it must produce OracleAS Wireless XML output. You can determine the request type with the wwctx_api.get_http_accept. It fetches the HTTP accept header, which indicates the request type. In the portlet response, you must set the MIME header to the appropriate value in the HTTP header before the portlet content is produced. If not, then the portlet response is rejected when the resulting page is built by Oracle Portal. If the call to get wwctx_ api.get_http_accept returns a string starting with textvnd.oracle.mobilexml, then you can assume it is a mobile request. Otherwise, it is a desktop request. In the case of a mobile request, you should set the MIME header to textvnd.oracle.mobilexml. In the case of a desktop request, you can explicitly set the MIME header to texthtml, but it is not required that you do so because its the default setting. If you want to produce HTML for desktop requests and OracleAS Wireless XML for mobile requests, the show procedure for your portlet should look similar to the following: procedure show p_portlet_record in out wwpro_api_provider.portlet_runtime_record is begin -- -- Does the portal want us to render the portlet contents? -- if p_portlet_record.exec_mode = wwpro_api_provider.MODE_SHOW then -- -- Is this a mobile request? -- if owa_util.get_cgi_envHTTP_ACCEPT like wwpro_login.CONTENT_TYPE_MOBILEXML || then -- -- This is a mobile request for the portlet contents -- call the mobile show contents procedure -- render_mobile_show_contentsp_portlet_record; else -- -- This is a desktop request for the portlet contents, -- call the desktop show contents procedure -- render_desktop_show_contentsp_portlet_record; end if; elsif -- check for other show modes, and handle them ... end show; has_show_link_mode Indicate whether you have implemented Link mode for the portlet. We recommend that all mobile portlets enable Link mode. The rationale for using Link mode is more fully explained when you reach step 3. Table 8–6 Cont. Portlet Record Attributes Attribute Description Creating PLSQL Portlets 8-49 If you want to produce only OracleAS Wireless XML for all requests, the show procedure for your portlet should look similar to the following: procedure show p_portlet_record in out wwpro_api_provider.portlet_runtime_record is begin -- -- Does the portal want us to render the portlet contents? -- if p_portlet_record.exec_mode = wwpro_api_provider.MODE_SHOW then -- -- This is either a desktop or mobile request for the portlet -- contents call the show contents procedure to render the -- OracleAS Wireless XML output -- render_show_contentsp_portlet_record; elsif -- check for other modes ... end show; In order to generate OracleAS Wireless XML, the render_show_contents or render_show_mobile_contents procedure would need to contain something similar to the following: ... p_portlet_record in out wwpro_api_provider.portlet_runtime_record is begin -- -- Set the MIME type to be Oracle9iAS Wireless XML -- owa_util.mime_headertextvnd.oracle.mobilexml; -- -- Output the Oracle9iAS Wireless XML markup -- htp.pSimpleTextSimpleTextItem; htp.pHello World; htp.pSimpleTextItemSimpleText; ... 3. If you want your portlet to allow personalization of titles for mobile rendering, you need to implement Link mode. Link mode is only called for mobile requests and it renders a link to the portlet content. This link appears in the menu of page contents when the user first navigates to the page. If a Link mode is not present for Note: As this is a mobile request the MIME header is set to textvnd.oracle.mobilexml. In the OracleAS Wireless XML markup, you only need to render the actual content. Oracle Portal fits it into the complete OracleAS Wireless XML document. You do not need SimpleResult or SimpleContainer tags. These tags are rendered by Oracle Portal along with a back link, which, by default, is assigned to one of the buttons on the mobile device.