Context Menu in Oracle APEX
At the beginning of August, I have released my next plugin for Oracle Application Express community. The plugin is released on behalf of Pretius company and it is available under MIT license. If you are interested in how the plugin has evolved through time and who made my mind to rewrite it from scratch then read the full article.
Pretius APEX Context Menu
The plugin uses the official Oracle APEX menu widget API to create a menu which can be attached to any HTML element in your APEX application. It uses APEX list as a base, but with simple JSON it is possible to extend it on dynamic action execution time:
- add new entries,
- create a submenu for an existing entry,
- change the behavior of an existing entry.
If you want to learn more about the plugin please refer those links:
- Live demo application at apex.oracle.com
- Documentation / download at GitHub
- The business use case for the plugin as my blog post at Pretius blog
The story behind the plugin
I have made my mind to make this plugin in the middle of the 3rd quarter of 2018 – a pretty long time ago. Back then I was working on the next application for one of Pretius clients. It was just the next APEX application to be migrated from Oracle Forms to Oracle APEX. Because of the number of actions that can be performed from particular views I had to think about the possibility to give all actions to end-users but without consuming too much space. I have described that business case at Pretius blog “Oracle APEX popup menu with Pretius APEX Context Menu“.
The first implementation (but not released) of the plugin looked like this:
As you can see, it looks and configuration attributes have changed drastically. In the first version, it was already using APEX list but I was embedding it using bootstrap popover. Thanks to it I was already able to aggregate multiple actions (respecting user privileges) into a report row menu. Moreover, I had control over a popup menu HTML structure so I could add extra HTML elements before and after the list.
I was really proud of the 1st version and I have decided to include it in a demo for my Apex Alpe Adria 2019 lecture. Back then I’ve promised that the plugin will be released 2 months after the conference. As you already know the release was delayed by 2 extra months. The reason for this is my unexpected meeting with #orclapex dev team at APEX Connect 2019 conference.
In the break between sessions, I have met Anthony Rayner. After short talking, we decided to have a small meeting regarding my plugin that won APEX Competition 2019 – Enhanced LOV item. He suggested to invite John Snyders as well, and while we were talking, Cesten Czarski joined us too.
We were talking about native enhanced popup LOV that will be available with APEX 19.2 – features I have covered with winning plugin. I was really excited about discussing my work with people responsible for APEX – we went through almost all of my plugins.
When I was showing the first implementation of the context menu, John Snyders commented it with more or less these words:
It should be done with popup menu
This comment made me think about the implementation and configuration possibilities. After a couple of days, I’ve started googling. The first resource was Johns blog post from 2015 about the native menu popup. In his article, he referenced API that was not described back then. Luckily for me, I got back to his article in 2019 and API was finally described. After some testing, I’ve decided to rewrite the plugin and delay the release date. You might ask a question “Why?”.
First of all, because John was right. If I would release 1st version #orclapex community would end up with a new low code component which is using an external library (bootstrap popover) that is not supported by Oracle APEX. What is more, look & feel was unfamiliar, not even close to Universal Theme other components. I was supporting Theme Roller integration via available classes but in fact, it was still “foreign body” among native-looking components.
Second of all, I wasn’t satisfied with the implementation and integration with Oracle APEX list. My first version was identifying list entries by label text – not so efficient, especially when you have more entries with the same text. The widget menu identifies entries by entry attribute 1 and it was the thing I needed. This change affected how the plugin can be customized via a JSON object which properties are mapped from the menu widget API. In my thinking possibility to override the entry behavior is a crucial feature just as respecting list entry authorization scheme result. Thus it should be simple to implement by other APEX developers – and everyone is familiar with template attributes, right?. What is more, thanks to the widget menu I was able to implement submenus without any extra cost because it now uses JSON object which is part of the menu widget.
Third of all, the menu widget is native APEX component and best practices in case of RAD and low code enjoin to use components that are available out of the box. The widget menu is a complete component and it serves to create a popup menu, not Anything-You-Want-Menu. Making plugins configuration as simple as possible is the right path to follow. Still, thanks to the widget I got much more in advance. If the menu widget won’t be rewritten from scratch the maintenance cost in the future will be much lower then maintaining my own implementation.
To sum it up, thanks to using the menu widget I’ve gained:
- a native-looking popup menu which looks and UX is part of the Universal Theme
- support for multi-level menu out of the box (which was a roadmap for the first version)
- lesser the plugin total weight
- no external library to handle popup menu container
- no CSS needed, its part of Universal Theme
Talking to the right person is the key to success and because of that, I would like to thank John Snyders for his simple and honest comment during our small meeting!