Saturday, 19 March 2011

Item Plugin Template

This is more a reference on how to create a basic item plugin - just a text field that is exactly the same as Text item type. There is a more detailed guide for those interested on the Oracle Learning Library -

A lot of the values to use in your plugin can be obtained from the t_page_item record, with one exception - the name attribute. For this, you need to use the function get_input_name_for_page_item. The reason for this is that APEX needs to be able to map this input field to an item in session state. This gets the necessary element name (i.e. p_t02) and adds the additional hidden element to the page - p_arg_names.

With that in mind, the most basic of plugins (well, render function) - that adds no extra functionality is:

function render_file_item(
    p_item                in apex_plugin.t_page_item,
    p_plugin              in apex_plugin.t_plugin,
    p_value               in varchar2,
    p_is_readonly         in boolean,
    p_is_printer_friendly in boolean )
    return apex_plugin.t_page_item_render_result
  l_result apex_plugin.t_page_item_render_result;
  l_name varchar2(200) := apex_plugin.get_input_name_for_page_item(false);
  if apex_application.g_debug then
        apex_plugin_util.debug_page_item (
            p_plugin              => p_plugin,
            p_page_item           => p_item,
            p_value               => p_value,
            p_is_readonly         => p_is_readonly,
            p_is_printer_friendly => p_is_printer_friendly );
    end if;

<input id="' || || '" type="text" name="' ||l_name ||'" value="' || p_value || '" />');
  return l_result;

Well, not a very helpful post, but gives the basic basis for a plugin item.