├── LICENSE ├── README.md └── source ├── ajax_region.sql ├── item_render.sql ├── jquery.ui.widgeName.js └── render_region.sql /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 OraOpenSource 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # apex-plugin-templates 2 | Oracle APEX plugin template files to help build your own templates. 3 | -------------------------------------------------------------------------------- /source/ajax_region.sql: -------------------------------------------------------------------------------- 1 | create or replace function ajax_region ( 2 | p_region in apex_plugin.t_region, 3 | p_plugin in apex_plugin.t_plugin ) 4 | return apex_plugin.t_region_ajax_result 5 | as 6 | l_result apex_plugin.t_region_ajax_result; 7 | 8 | -- TODO mdsouza: reference region & plugin parameters 9 | 10 | -- %PLUGIN_ATTRIBUTES% 11 | 12 | -- %REGION_ATTRIBUTES% 13 | 14 | -- %AJAX_ATTRIBUTES% 15 | 16 | -- TODO mdsouza: 17 | -- AJAX attributes 18 | -- Rename to meaninful variable 19 | l_ajax_01 apex_application.g_x01%type := apex_application.g_x01; 20 | 21 | 22 | 23 | begin 24 | 25 | -- %DEBUG_REGION% 26 | 27 | 28 | -- CODE 29 | 30 | -- Assuming that AJAX call is of type JSON, then need to return a JSON result back 31 | -- Return results 32 | -- Select the appropriate type based on the call made from JS 33 | -- Modify the messages accordingly 34 | -- TODO mdsouza: Have different return types base on the AJAX call 35 | 36 | -- JSON 37 | sys.htp.p('{' || 38 | apex_javascript.add_attribute( 39 | p_name => 'success', 40 | p_value => true, 41 | p_add_comma => false) || '}'); 42 | return l_result; 43 | 44 | -- Need to return something (JSON data) 45 | -- https://community.oracle.com/message/13088553?et=watches.email.thread#13088553 46 | -- sys.owa_util.status_line(204, 'No Content'); 47 | end ajax_region; 48 | / 49 | -------------------------------------------------------------------------------- /source/item_render.sql: -------------------------------------------------------------------------------- 1 | function item_render ( 2 | p_item in apex_plugin.t_page_item, 3 | p_plugin in apex_plugin.t_plugin, 4 | p_value in varchar2, 5 | p_is_readonly in boolean, 6 | p_is_printer_friendly in boolean ) 7 | return apex_plugin.t_page_item_render_result 8 | as 9 | l_html varchar2(32767); -- Dummy variable to store HTML 10 | 11 | l_input_name := apex_plugin.get_input_name_for_page_item(p_is_multi_value => false); 12 | l_ajax_id := apex_plugin.get_ajax_identifier; 13 | 14 | l_result apex_plugin.t_page_item_render_result; -- Result object to be returned 15 | 16 | 17 | -- %PLUGIN_ATTRIBUTES% 18 | 19 | -- %ITEM_ATTRIBUTES% 20 | 21 | begin 22 | 23 | -- %DEBUG_ITEM% 24 | 25 | -- handle read only and printer friendly 26 | if p_is_readonly or p_is_printer_friendly then 27 | -- omit hidden field if necessary 28 | apex_plugin_util.print_hidden_if_readonly ( 29 | p_item_name => p_item.name, 30 | p_value => p_value, 31 | p_is_readonly => p_is_readonly, 32 | p_is_printer_friendly => p_is_printer_friendly); 33 | 34 | -- omit display span with the value 35 | apex_plugin_util.print_display_only ( 36 | p_item_name => p_item.name, 37 | p_display_value => p_value, 38 | p_show_line_break => false, 39 | p_escape => true, -- this is recommended to help prevent XSS 40 | p_attribute => p_item.element_attributes); 41 | else 42 | -- Not read only 43 | 44 | -- TODO mdsouza: How do do teh set/get methods for item 45 | 46 | 47 | end if; -- read only 48 | 49 | return l_result; 50 | end item_render; 51 | / 52 | -------------------------------------------------------------------------------- /source/jquery.ui.widgeName.js: -------------------------------------------------------------------------------- 1 | // TODO mdsouza: Ask Dan to review this. 2 | // uiw = UIWidget. Shortcut to help handle what "this" is 3 | 4 | 5 | //Enter widget name. Usually ui.widgetName 6 | $.widget('ui.widgetName', { 7 | /** 8 | * Examples are included in this code. 9 | * They will all assume that the widgetName is 'ui.foo' 10 | * and it's being applied against jQuery object $('#bar') 11 | */ 12 | 13 | 14 | /** 15 | * Default options 16 | * 17 | * @example 18 | * As part of Widget initialization: $('#bar').foo({'abc': 'def'}); 19 | * Setting after: $('#bar').foo('option', 'abc', 'def'); 20 | * Getting: var myVal = $('#bar').foo('option', 'abc'); 21 | */ 22 | options: { 23 | ajaxId : '' // This is the ajaxId for the plugin's AJAX functions to reference 24 | }, 25 | 26 | // TODO mdsouza: debugging 27 | // TODO mdsouza: Add this to all the functions. 28 | // TODO mdsouza: Need a way to close up (general exception handle) 29 | /** 30 | * Starts debugging for a function 31 | * @param pGroupName Name of group for collapsed debugging 32 | * @param pThis the "this" object of the calling function 33 | */ 34 | _debugFunction: function(pGroupName, pThis){ 35 | // TODO mdsouza: Wrapper for Console required 36 | 37 | var uiw = this; 38 | console.groupCollapsed(uiw._scope + '.' + pGroupName); 39 | console.log('this:', pThis); 40 | 41 | var 42 | //This is the function that called this function 43 | callingFn = arguments.callee.caller, 44 | // Got following line from: http://stackoverflow.com/questions/914968/inspect-the-names-values-of-arguments-in-the-definition-execution-of-a-javascript 45 | // Get the name of all the arguments in the function. 46 | argList = /\(([^)]*)/.exec(callingFn)[1].split(','), 47 | // Array of arguments passed into the calling function (not this function) 48 | args = Array.prototype.slice.call(callingFn.arguments); 49 | 50 | //Display each argument 51 | for(var i = 0, iMax = args.length; i < iMax; i++) { 52 | if (i === 0){ 53 | console.log('Arguments'); 54 | } 55 | 56 | if (i < argList.length){ 57 | console.log(argList[i].trim() + ':', args[i]); 58 | } 59 | else { 60 | //Unassigned 61 | console.warn('unassigned:', args[i]); 62 | } 63 | }//for 64 | 65 | 66 | }, //_debugFunction 67 | 68 | /** 69 | * Set private widget varables. 70 | * Thes are not accesible outside of the widget 71 | */ 72 | _setWidgetVars: function(){ 73 | var uiw = this; 74 | 75 | //No Auto Debug here since _scope is not yet set 76 | 77 | // TODO mdsouza: are we still going to use scope? 78 | uiw._scope = 'ui.toggleFontSize'; //For debugging 79 | 80 | uiw._values = { 81 | }; 82 | 83 | //Enter elements here for quick reference 84 | //If jQuery object, prefix with "$" 85 | uiw._elements = { 86 | $element : $(uiw.element) 87 | }; 88 | }, //_setWidgetVars 89 | 90 | /** 91 | * Create function: Only called the first time the widget is assiocated to the object 92 | * Will implicitly call the _init function after 93 | */ 94 | _create: function(){ 95 | var uiw = this; 96 | 97 | uiw._setWidgetVars(); // Set variables (don't modify this) 98 | 99 | var consoleGroupName = uiw._scope + '_create'; 100 | $.console.groupCollapsed(consoleGroupName); 101 | $.console.log('this:', uiw); 102 | 103 | //CODE that only needs to be run only once when widget is applied to object 104 | //Ex: uiw._values.fontSize = uiw._elements.$element.css('fontSize'); 105 | 106 | $.console.groupEnd(consoleGroupName); 107 | },//_create 108 | 109 | /** 110 | * Init function. This function will be called each time the widget is referenced with no parameters 111 | */ 112 | _init: function(){ 113 | var 114 | uiw = this, 115 | // TODO mdsouza: Is there a way to find the current function name in a function? 116 | consoleGroupName = uiw._scope + '_init'; 117 | 118 | _debugFunction(consoleGroupName, uiw); 119 | 120 | //CODE 121 | //Code here will be run each time the widget is called without params 122 | 123 | $.console.groupEnd(consoleGroupName); 124 | }, //_init 125 | 126 | 127 | /** 128 | * Public functions here 129 | * 130 | * @example 131 | * //Define public function 132 | * getBaseFontSize: function(){ 133 | * var 134 | * uiw = this, 135 | * consoleGroupName = uiw._scope + 'getBaseFontSize'; 136 | * 137 | * $.console.groupCollapsed(consoleGroupName); 138 | * $.console.log('this:', uiw); 139 | * return uiw._values.baseFontSize; 140 | * },//getBaseFontSize 141 | * 142 | * 143 | */ 144 | 145 | // TODO mdsouza: Example call to AJAX 146 | 147 | // TODO mdsouza: Look into docs on proper destroy function 148 | /** 149 | * Removes all functionality associcated with widget 150 | * In most cases in APEX this won't be necessary 151 | * 152 | * @example // TODO mdsouza: 153 | */ 154 | destroy: function() { 155 | var uiw = this; 156 | $.console.log(uiw._scope, 'destroy', uiw); 157 | 158 | //restore the font size back to its original size 159 | uiw._elements.$element.css('fontSize', uiw._values.baseFontSize); 160 | 161 | $.Widget.prototype.destroy.apply(uiw, arguments); // default destroy 162 | }//destroy 163 | 164 | }); //ui.widgetName 165 | -------------------------------------------------------------------------------- /source/render_region.sql: -------------------------------------------------------------------------------- 1 | create or replace function render_nest ( 2 | p_region in apex_plugin.t_region, 3 | p_plugin in apex_plugin.t_plugin, 4 | p_is_printer_friendly in boolean ) 5 | return apex_plugin.t_region_render_result 6 | as 7 | subtype plugin_attr is varchar2(32767); 8 | 9 | -- Variables 10 | l_result apex_plugin.t_region_render_result; 11 | l_html varchar2(32767); -- Dummy variable to store HTML 12 | l_ajax_id := apex_plugin.get_ajax_identifier; 13 | 14 | -- Only required if planning to use AJAX 15 | l_ajax_identifier varchar2(255) := apex_plugin.get_ajax_identifier; 16 | 17 | -- Applicaion attributes 18 | -- these are plugin attributes that are shared amongst all instances of the plugin 19 | -- defined in shared components > plugins > > custom attributes 20 | -- rename to meaninful variable 21 | l_app_val_01 plugin_attr := p_plugin.attribute_01; 22 | 23 | -- Component attributes 24 | -- these are plugin attributes specific to each instantiation of the plugin 25 | -- defined when modifying the plgin object 26 | -- rename to meaninful variable 27 | l_comp_val_01 plugin_attr := p_region.attribute_01; 28 | 29 | begin 30 | -- debug information will be included 31 | if apex_application.g_debug then 32 | apex_plugin_util.debug_region ( 33 | p_plugin => p_plugin, 34 | p_region => p_region, 35 | p_is_printer_friendly => p_is_printer_friendly); 36 | end if; 37 | 38 | -- CODE 39 | 40 | -- Example of how to call custom jQuery Widget 41 | -- Delete if not using a widget 42 | l_html := q'!$("#%ID%").widgetName({'ajaxId' : '%AJAX_ID' })!'; 43 | l_html := replace(l_html, '%ID%', p_region.static_id); 44 | l_html := replace(l_html, '%AJAX_ID%', l_ajax_id); 45 | 46 | apex_javascript.add_onload_code(p_code => l_html); 47 | 48 | return l_result; 49 | end render_nest; 50 | / 51 | --------------------------------------------------------------------------------