APEX 5.0: Directory Support for Static Plug-in Files

Since day one, the APEX Plug-in framework provided the capability to create self containing installations which included all static files needed by the Plug-in. But this file storage was somehow limited in APEX 4.x, because it didn’t allow to reference files with a relative URL.

One of the use cases where you need relative URLs is if you want to reference an image in a CSS file. In APEX 4.x you had to modify the CSS file and use #PLUGIN_PREFIX# instead of the relative URL. This was cumbersome because if your Plug-in used 3rd party files, you had to make that modification each time when you included a new version. In addition if you provided your static plug-in files as a separate download to put them for better performance on a web server, you had to maintain two versions of the files.

In Oracle APEX 5.0 we allow to define a Directory Structure for Static Plug-in Files where the files can be referenced with relative URLs. No need to modify CSS files, no need for the #PLUGIN_PREFIX# substitution anymore! Just upload the ZIP file containing all 3rd party files and APEX will automatically unpack the file and keep the directory structure defined in the ZIP file.

Static Plug-in Files with Directory Support

Files will be referenced with

background-image: url("images/star.gif");

That’s all!

If an administrator wants to improve performance of a plug-in on a production system, he can just grab all files, modify the File Prefix attribute and put all static files on a web server. Speaking about production deployment and Runtime Only systems. When an application is installed on the command line, the apex_application_install.set_static_plugin_file_prefix api can be used to change the File Prefix value on the fly. This will provide the flexibility that on development and test, you can keep all files self contained in the application but on a production system optimize file access for better performance.

begin
    apex_application_install.set_static_plugin_file_prefix(
        p_plugin_type => 'ITEM TYPE',
        p_plugin_name => 'COM.ORACLE.APEX.STAR_RATING',
        p_file_prefix => '/plugins/starrating/' );
end;
/
@f46846.sql

Note: The substitution #PLUGIN_PREFIX# is desupported and will not work anymore in APEX 5.0. But no worries! If you import or upgrade a plug-in which uses it in a static file then we will automatically remove it because it’s not needed anymore.