As I haven’t done it this way before, I tried to make a setup to support it. In this blog post, I will describe how I separated my files on a local installation of Oracle XE 18c. My local instance is set up like this:
- Windows 10
- Oracle XE 18c (18.4)
- Apache Tomcat 8.5.4
- ORDS 19.1
- APEX 19.1
The installation guide for basic Tomcat+ORDS setup (Link) tells us to copy the APEX Images folder from the installation archive to the webapps folder of the Tomcat installation directory, and then to rename it to “i”. If we put some of our own files into this directory, they can immediately be referenced in APEX by using the #IMAGE_PREFIX# substitution string, e.g. #IMAGE_PREFIX#apex_custom/css/my_styles.css
But instead of this, you can use a path anywhere on your computer and leave the APEX Images folder untouched. I did this by creating a folder and then defining a PostResource pointing to this folder, in the Tomcat configuration.
To do this, make the following steps:
2) Put your static files inside the apex_custom folder, e.g.:
3) Open the server.xml file from the Tomcat installation directory:
..\Tomcat 8.5\conf\
<Context docBase="C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\apex_custom" path="/apex_custom" />
Here is a screenshot from the file itself:
The Context docBase "path" property is a symbolic name by which your folder will be accessed, but to keep things simple, here it is the same as the folder name. You can change this to your needs and you can add any folder on your computer this way.
5) Save server.xml file changes and restart your Tomcat server, e.g. in the Command Prompt:
net stop Tomcat8, and afterwards
net start Tomcat8
You should see the file contents. If you get the 404 error, review your previous configuration steps.
The same files in N++:
7) Let’s move on to APEX. To reference this new folder, go to Application Properties of your App, and in the bottom of the Definition tab you will find Substitution Strings.
Define a new string APEX_CUSTOM_JS, with the value of /apex_custom/js/
Also, define a new string APEX_CUSTOM_CSS, with the value of /apex_custom/css/
Apply Changes.
8) You should now be able to reference your static files:
a. On Page Template level,
b. Or on Page level
* Tip: If you need to edit Templates, you should create a copy of an existing template and then make changes to the copy. Never unsubscribe default templates from the Universal Theme.
9) Finally, test it in your App:
Cheers!
Daniel