Posts

Showing posts from March, 2011

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