Posts

AJAX File Upload

Image
Ok, so I looked into this a while ago, and had all the idea's in my head, but just never got around to putting something together. Some of the newer HTML5 File API's allow you to access the file contents (base64 is what we like) - by using the FileReader object. Unfortunately, not all browsers have support for it, so you would not be able to use it accross the board. There are a lot of resources on the topic. If interested, check out: http://www.html5rocks.com/tutorials/file/dndfiles/ and https://developer.mozilla.org/en/Using_files_from_web_applications . There is another plugin out there, which supports ajax uploads with IE, but unfortunately it's commercial; which is another reason I was keen to get this happening. So anyway, I've created a demo of this - which you can check out at: http://apex.oracle.com/pls/apex/f?p=45448:afu I used the following table to get started: CREATE TABLE PLUGIN_BLOB ( ID NUMBER NOT NULL , MIME_TYPE VARCHAR2(200) , FILENAME...

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 - http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r40/apexplugins/apexplugins_ll.htm 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 ...

Expand and Collapse all Tree Nodes

APEX comes with a nice region type which is a tree view. During the wizard creation, you have the option to add buttons to expand all and collapse all nodes - but after the fact, there is no option in the tree settings to add this functionality - so you either have to recreate the tree region specifying that option or have to know what you have to do in order to add in that functionality. I came across this post on the OTN forums - http://forums.oracle.com/forums/message.jspa?messageID=4407552#4407552 - which give all the information about what you have to do to expand and collapse all nodes (I'm sure there are others, but that just happened to be the one I found). This basic gist of it is this - there are two convenience functions to do the expanding and collapsing of all nodes - apex.widget.tree.expand_all(tree_id) and apex.widget.tree.collapse_all(tree_id), respectively - where tree_id is the unique identifier of the tree. You can either hard code it in (which is what is do...

Google Visualization API (Org Chart)

Wanted to have a go at making a family tree, and came across this API. It is worth noting this particular chart doesn't allow you to specify more than one node for the parent, so not exactly perfect for a family tree. See:  http://code.google.com/p/google-visualization-api-issues/issues/detail?id=162 . I believe it worthwhile to read the getting started guide for google visualizations: http://code.google.com/apis/visualization/documentation/using_overview.html and the actual guide for using the organizational chart: http://code.google.com/apis/visualization/documentation/gallery/orgchart.html . Why use this over the charts provided in APEX? For one thing, there is no organizational chart available, to my knowledge. For another, it is not flash ;-) That can only be a good thing! Alright, down to business. Firstly create a table to store the data: CREATE TABLE "PERSON" ( "PERSON_ID" NUMBER NOT NULL ENABLE, "NAME" VARCHAR2(200 BYT...

APEX AJAX Basics

Introduction I'll start of by saying this post isn't about achieving any particular task via AJAX - there are plenty of examples out there already - but how to perform AJAX with Application Express. There seems to be no official documentation on the matter, so wanted to do a general overview on how to achieve AJAX techniques. Of course, it is also worth mentioning, writing your own AJAX functions is not so necessary anymore, with the addition of Dynamic Actions in APEX 4. Never the less, it is still worth knowing. The most common technique for AJAX in Application Express is to have PL/SQL code in an on demand process, and then calling that process via Javascript at run time. Application Express provides a helper function for calling an on demand process, and that is htmldb_Get (and additionally, apex.ajax.ondemand which is effectively a wrapper object for htmldb_Get object). With the release of APEX 4, came the jQuery library included - so another option for using AJAX is...

Checking all Check boxes in a Manual Tabular Form

If you get into edit all page processes on one of your pages, you'll notice that the second tab accross is titled 'Delete multiple processes' (7400:745). This page also provides the same functionality, for checking all checkboxes in the column. You'll notice this elements onclick function is html_CheckAll($x_UpTill(this,'TABLE'),this.checked) So, in your column header, using this will give you the same behaviour <input type="checkbox" onclick="html_CheckAll($x_UpTill(this,'TABLE'),this.checked)" /> It is worth noting that html_CheckAll is not an apex documented function, so should be used with caution. In saying that, it is just  a wrapper for $f_CheckAll, which is documented - so it should be safe to use that function call instead of html_CheckAll. So the better input type would look like: <input type="checkbox" onclick="$f_CheckAll($x_UpTill(this,'TABLE'),this.checked)" /> The fu...

CSV Upload into Oracle Table

The first thing you need is a page with a file type item, and a submit button. When you submit the page, the selected file is uploaded into the apex_application_files (or wwv_flow_files) view. The actual blob contents of the file is uploaded into the column BLOB_CONTENT but since a CSV file is just plain text, it made sense to me to convert that file to a CLOB, so that you can perform regular string functions on the data. The first reference to converting a blob to a clob, was in the OTN forums  - confirmed by referring to the oracle documentation . After converting it to a clob, it is simply a matter of looping over each row of the data, and then populating into an apex collection (or some other temp table). This is an intermediary step just so you can review the data before committing the changes. Finally, you just move the data from the collection into the table. So the code for copying the blob into a clob and populating the collection can be seen below. declare --variabl...