Skip to main content

Dynamic 'My Favorites' Links in your APEX Application

For a (even more) Web 2.0 like look-and-feel in your APEX application you can define a dynamic region 'My Favorite Tasks', that shows links to the pages you visit most frequently.
For these favorites we can query the APEX repository. Follow these steps to get this thing working:

  1. Enable logging on Application Level. Enabling the logging will result in records in the view apex_workspace_activity_log.
  2. Create a Report Page with a region based on a SQL Query.
  3. Enter the query to show the links for the three most visited pages:
select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSION
, page_name ) Task
from

(
select page_name
, page_id
, count(*)
from apex_workspace_activity_log
where application_id = :APP_ID
and apex_user = :APP_USER
and page_id <> :APP_PAGE_ID
group by page_name, page_id
order by 3 desc
)
where rownum <= 3
In a next post I will show how you can embed this report page in any other page in your application.

Comments

Anonymous said…
Nice Post Roel,

This can also be done using apex view apex_activity_log instead of wwv_flow_activity_log. Using apex_activity_log you would not need steps 1 and 2.

Thanks,
Todd
Stew said…
For those who were initially as clueless as me when they read "Enable logging on Application Level", that means to navigate to Shared Components -> Application Definition and set Logging := Yes in the Name section.

Stew
Stew said…
Roel,

It looks like the better bet would be to use the apex_workspace_activity_log table, since it's already granted to the workspace.

I'd use an inner query like:

SELECT *
FROM (SELECT page_id, page_name, MIN(seconds_ago) last_ones
FROM apex_workspace_activity_log
WHERE application_id = :APP_ID
AND page_id <> 101 -- Login page
AND userid = :APP_USER
GROUP BY page_id, page_name)
WHERE rownum <= 3
ORDER BY 3;

Or maybe I'm missing something?
Roel said…
Todd & Stew,

A combination of both suggestions seems to result in the best query:
- use apex_workspace_activity_log instead of the wwv_flow_activity_log (although the apex_.. view only contains data of the last 14 days).
- I think I don't have to exclude the login page, as there is no known user at the time that page pops up.
- the ORDER_BY should be inside the inline view, otherwise you don't get the Top-3.
- use APEX_USER instead of USERID
- exclude the current page from the query by filtering on :APP_PAGE_ID

I updated my post with your suggestions!

Thanks,
Roel
Simon Gadd said…
Excellent Roel.

I really like this.

One thing I found though was that my development team and I use some quite obscure 'Developer' coded page titles (e.g. Developer initials, module reference etc) and the Page Names are set to something more user friendly, after all, the Page Name is what the user sees at the top of their web browser.

A join in the query, as shown below, gave us a more user friendly result. Of course, if your page names and titles are the same then you needn't bother.

Just my thoughts.

As I said, nice post.

select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSION
, page_title ) "Favourite Pages"
from
(
select aap.page_title
, awal.page_id
, count(awal.page_id)
from apex_workspace_activity_log awal
join APEX_APPLICATION_PAGES aap on aap.application_id = awal.application_id and aap.page_id = awal.page_id
where awal.application_id = :APP_ID
and awal.apex_user = :APP_USER
and awal.page_id <> :APP_PAGE_ID
group by aap.page_title, awal.page_id
order by 3 desc
)
where rownum <= 3
Stew said…
Nice collaboration guys! :-)
Anonymous said…
Hi this adaptation will only show pages that are linked to from tabs:

select htf.anchor( 'f?p='||:APP_ID||':'||page_id||':'||:APP_SESSION, page_name ) Task
from (select act.page_name
, act.page_id
, count(*) "load_count"
from APEX_APPLICATION_TABS tab
join APEX_WORKSPACE_ACTIVITY_LOG act on tab.tab_page = act.page_id
where act.application_id = :APP_ID
and act.apex_user = :APP_USER
and act.page_id <> :APP_PAGE_ID
group by act.page_name, act.page_id
order by 3 desc)
where rownum <= 10;

Greets,
Maurice Kremer

Popular posts from this blog

apex_application.g_f0x array processing in Oracle 12

If you created your own "updatable reports" or your custom version of tabular forms in Oracle Application Express, you'll end up with a query that looks similar to this one:
then you disable the "Escape special characters" property and the result is an updatable multirecord form.
That was easy, right? But now we need to process the changes in the Ename column when the form is submitted, but only if the checkbox is checked. All the columns are submitted as separated arrays, named apex_application.g_f0x - where the "x" is the value of the "p_idx" parameter you specified in the apex_item calls. So we have apex_application.g_f01, g_f02 and g_f03. But then you discover APEX has the oddity that the "checkbox" array only contains values for the checked rows. Thus if you just check "Jones", the length of g_f02 is 1 and it contains only the empno of Jones - while the other two arrays will contain all (14) rows. So for processing y…

Refresh selected row(s) in an Interactive Grid

In my previous post I blogged about pushing changed rows from the dabatase into an Interactive Grid. The use case I'll cover right here is probably more common - and therefore more useful!

Until we had the IG, we showed the data in a report (Interactive or Classic). Changes to the data where made by popping up a form page, making changes, saving and refreshing the report upon closing the dialog. Or by clicking an icon / button / link in your report that makes some changes to the data (like changing a status) and ... refresh the report.  That all works fine, but the downsides are: The whole dataset is returned from the server to the client - again and again. And if your pagination size is large, that does lead to more and more network traffic, more interpretation by the browser and more waiting time for the end user.The "current record" might be out of focus after the refresh, especially by larger pagination sizes, as the first rows will be shown. Or (even worse) while you…

Dockerize your APEX development environment

Nowadays Docker is everywhere. It is one of the main components of Continuous Integration / Continuous Development environments. That alone indicates Docker has to be seen more as a Software Delivery Platform than as a replacement of a virtual machine.

However ...

If you are running an Oracle database using Docker on your local machine to develop some APEX application, you will probably not move that container is a whole to test and production environments. Because in that case you would not only deliver a new APEX application to the production environment - which is a good thing - but also overwrite the data in production with the data from your development environment. And that won't make your users very excited.
So in this set up you will be using Docker as a replacement of a Virtual Machine and not as a Delivery Platform.
And that's exactly the way Martin is using it as he described in this recent blog post. It is an ideal way to get up and running with an Oracle database …