Implementing the Portlet Package

8-12 Oracle Fusion Middleware Developers Guide for Oracle Portal 4. Add a constant called PORTLET_FIRST. This constant is used as the identifier for the portlet within the provider. Hence, the constants value must be unique within the provider. CREATE OR REPLACE package STARTER_PROVIDER is This package is used as an example to show how providers can be created in the portal system. This provider contains the following portlets: Hello World PORTLET_HELLOWORLD Snoop PORTLET_SNOOP PORTLET_HELLOWORLD constant integer := 1; PORTLET_SNOOP constant integer := 2; PORTLET_FIRST constant integer := 3; 5. Save starter_provider2.pks. 6. Open starter_provider2.pkb in an editor. 7. In starter_provider2.pkb, add a call for the new portlets get_portlet_ info function in the get_portlet function of the provider package. This step entails adding the call my_first_portlet.get_portlet_info in the get_ portlet function. The get_portlet function allows the portal to retrieve information for the portlet when necessary. function get_portlet p_provider_id in integer ,p_portlet_id in integer ,p_language in varchar2 return wwpro_api_provider.portlet_record is begin if p_portlet_id = PORTLET_HELLOWORLD then return helloworld_portlet.get_portlet_info p_provider_id = p_provider_id ,p_language = p_language ; elsif p_portlet_id = PORTLET_SNOOP then return snoop_portlet.get_portlet_info p_provider_id = p_provider_id ,p_language = p_language ; elsif p_portlet_id = PORTLET_FIRST then return my_first_portlet.get_portlet_info p_provider_id = p_provider_id ,p_language = p_language ; else raise wwpro_api_provider.PORTLET_NOT_FOUND_EXCEPTION; end if; end get_portlet; 8. In starter_provider2.pkb, add the new portlet to the list of portlets returned by the provider. This step entails adding the new portlet to the get_portlet_ Creating PLSQL Portlets 8-13 list function of the provider. The get_portlet_list function tells the portal which portlets the provider implements. function get_portlet_list ... begin l_cnt := 0; if p_security_level = false then l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_HELLOWORLD ,p_language = p_language ; l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_SNOOP ,p_language = p_language ; l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_FIRST ,p_language = p_language ; else if helloworld_portlet.is_runnable p_provider_id = p_provider_id ,p_reference_path = null then l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_HELLOWORLD ,p_language = p_language ; end if; if snoop_portlet.is_runnable p_provider_id = p_provider_id ,p_reference_path = null then l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_SNOOP ,p_language = p_language ; end if; if my_first_portlet.is_runnable p_provider_id = p_provider_id ,p_reference_path = null then l_cnt := l_cnt + 1; l_portlet_listl_cnt := get_portlet p_provider_id = p_provider_id ,p_portlet_id = PORTLET_FIRST ,p_language = p_language ; end if; end if;