Implementing Expiry-Based Caching Improving Portlet Performance with Caching

Creating PLSQL Portlets 8-37 is begin wwpro_api_invalidation.invalidate_by_instance p_provider_id = p_provider_id, p_portlet_id = p_portlet_id, p_instance_id = p_instance_id, p_user = wwctx_api.get_user; owa_util.redirect_urlp_page_url; end map_invalidation; 3. In the show procedure, add a link for refreshing the portlet before the code that draws the map. For example: Draw the Refresh Me link htp.anchor curl = wwctx_api.get_user|| .map_invalidation?p_provider_id=||p_portlet_record.provider_id|| p_portlet_id=||p_portlet_record.portlet_id|| p_instance_id=||p_portlet_record.reference_path|| p_page_url=||utl_url.escape url = p_portlet_record.page_url, escape_reserved_chars = TRUE, ctext = wwui_api_portlet.portlet_text p_string =Refresh Me, p_level = 1 ; 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.9 Implementing Error Handling

Oracle Portal provides the capability for you to trap erroneous input and return meaningful error messages. It manages the internal error stack by tracking the raised exceptions and retaining information about them. Oracle Portal also includes a set of APIs for presenting errors in a standardized way. Error handling services are available through the wwerr_api_error and wwerr_ api_error_ui packages. These error handling services include the following key features: ■ Error stack . Oracle Portal uses an error stack to keep track of the error messages. When an error occurs, the error message is pushed onto an error stack. Whenever procedures or function calls are nested, the error stack keeps track of all the error messages. You can choose to retrieve only the top error or most recent error by using the wwerr_api_error.get_top method. Alternatively, you can get all the error messages on the stack using the wwerr_api_error.get_errors function. The stack can also be checked for the presence of any errors by calling the wwerr_api_error.is_empty function. ■ Error messages . Error handling services provide a way to define meaningful error messages. To define your own error messages, you need to define their name space. The name space consists of the following: – Name is the error name. 8-38 Oracle Fusion Middleware Developers Guide for Oracle Portal – Domain is the area of the product where the error occurred. – Subdomain is the subsystem where the error occurred. – Context is the name of the function where the error occurred. The name space uniquely identifies your error message. If it does not do so, a wwc-0000 error message is generated. The default domains include the portal WWC, application WWV, and page groups WWS. Each domain is further classified into subdomains, which define the object types. The portal domain includes the portlet, page, and document object types. The application domain includes object types such as forms, menus, reports, and charts. The page group domain includes object types such as pages, items, categories, and perspectives. If you need to define an error that does not fall within these classifications, you can define your own domain with subdomains for your errors. ■ Message parameters . The other language strings that you create for your errors can take substitution parameters for your messages. The p1, p2, p3... parameters can be used to pass substitution parameters to the error messages. For example, for this string: domain=yahoo, subdomain=provider, name=generalerror, string=Error: 1 an error can be added as follows: wwerr_api_error.addp_domain=yahoo, p_sub_domain=provider, p_name=generalerror, p_context=yahoo.show, p1= sqlerrm; ■ Error display . The wwerr_api_error_ui package provides a means to generate a standard user interface for displaying the errors in Oracle Portal. The error messages can be displayed in the following two ways: – Full screen user interface: These error messages are displayed in a full screen mode. You may want to display full screen errors when the system encounters fatal or show-stopper errors. – Inline user interface: These error messages are displayed within the current page itself. You may use inline errors for minor errors or warnings. Additionally, you can choose the output format of the display HTML, XML, or ASCII text.

8.9.1 Using Error Handling

In general, you set up error handling as follows: 1. On detecting error conditions, add the error message, with an appropriate domain and sub-domain combination, to the stack using the wwerr_api_error.add procedure. 2. When necessary for example, at the end of a routine, expose the error messages using the wwerr_api_error_ui procedures. To display full screen messages, use the procedures show_html, show_xml, or show_text depending on your preferred output type. To display inline messages, use the procedures show_ inline_html, show_inline_xml, or show_inline_text, depending on the output type you desire. Guidelines for Error Handling While implementing error handling, keep in mind the following: