Add a Clone Session button to your APEX application


Our customer wants to compare values in an Interactive Report in our custom-built application. To achieve this he copies the URL from the original report (with some filters applied), and pastes it into a new page (or tab) in the browser. Then he applies new filtering to the copied report, and compares it with the original report. So far so good, but when he want to change the filtering on the original report, it become a mess. That is because both reports belong to the same APEX session, so when the new filtering is applied to the copied report, that filtering is stored in session state. Refreshing the original report then retrieves session state, and automatically applies the new filtering.
Having both reports in a different session would solve the problem. This can be achieved by session cloning (in the APEX documentation, look under App Builder Concepts => Managing Session State Values). The idea is to open a new page (or tab) with the same URL, but with a request “APEX_CLONE_SESSION“ added. Again, from the APEX documentation:
To use session cloning, the developer must provide a method for end user to open a new browser tab and specify the
REQUEST
value ofAPEX_CLONE_SESSION
. The following is an example URL:
f?p=&APP_ID.:&APP_PAGE_ID.:&APP_SESSION.:APEX_CLONE_SESSION
So for our customer we decided to add a “Clone session“ button to the top navigation bar. To do this, we added a new List Entry to the Navigation Bar list, before the other entries:
We provide the URL as suggested in the documentation, and added the &DEBUG. to be able to debug across the session. For clarity for our customer we added the fa-copy
icon to the button.
Now we have a nice “Clone session” in our top navigation bar, but when we click it, it doesn’t open a new tab, but it opens a new session on top of the current session, thereby losing the original session. That is not our intention, so there is one more thing we have to do:
In the List Entry, when we scroll down we see a number of User Defined Attributes, that are available in the Navigation Bar List template. Number 6 is called Link Target, so that is where we can control the target behaviour. We fill in “_blank“, to make sure the link opens in a new tab:
Now our “Clone session“ button behaves as intended.
An example of the button can be found in my Demo application at https://apex.oracle.com/pls/apex/r/kwintup/put-post-blog/home (login with demo/andre).
Subscribe to my newsletter
Read articles from André van der Put directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
