Sunday, November 10, 2019

Region Display Selector - How to Prevent Scroll on Page Load

A few days ago I visited my dear friends Aljaž Mali and Andrej Grlica and they had one interesting case. They had a page where they used region display selector in Scroll Window mode to display some regions in tabs. Since region display selector wasn't positioned on top of the page, on page load navigation was scrolled down to the first tab region (as in this example).

To fix it, the first thought from Andrej and me was to somehow do it with JavaScript, but after we examined JS API we concluded that there isn't any clean solution.

And then, as always, four eyes are better than two...we came out with a nice but dirty solution.

The Fix

To fix it you need to:
  • create a dummy region with Region Display Property turned on an put it before all other regions with that property on
  • use region template - Blank with Attributes 
  • add Static ID (in our case it was noScrollTab)
  • add the following CSS to the page either as inline CSS or to the external static file (preferred way)


What have we done here? We created a region on the first position in region display selector - the region that usually is scrolled down to on page load and then with CSS we've positioned it to the top left corner of the page and hid it.

The demo is available here.

Tested in APEX


Thursday, November 7, 2019

APEX 19.2: Finally, API for component export

I don't remember when I was so excited about the new APEX feature as at the moment when I've discovered that there's a new parameter in procedure apex_export.get_application called p_components that enables component export. I know, it's small, but it opens a big playground.

Maybe the reason for this excitement is that for some time now, I'm working on an APEX app for creating patches of database object and APEX components and the only missing piece was API for component export. I had that working before APEX 19.2, but I had to use an internal export procedure which is not so convenient.

The only thing that you could do with the apex_export API before 19.2 was to export a whole application or all components in some predefined structure.

From APEX 19.2 you can export any component that you want through the API. So, how can you do that...

The Code...

... is pretty straight forward. Just select component from a new dictionary APEX_APPL_EXPORT_COMPS. The columns that you need for component export are TYPE_NAME and ID, for example:

Then you should combine them in the array in form TYPE_NAME:ID (currently there's a bug in 19.2 docs, where you can find that the array values should be formed as TYPE:NAME):

The output of the get_application procedure is a table of apex_t_export_file (with name and contents columns). Name column will always have same value (in format f{APP_ID}_components.sql, for example, f100_components.sql) and the contents column will have export code (as a CLOB). No matter how many components do you add to the array you'll always get only one file/element as an output. The only time when you can get more files is if you set p_split parameter to true.

After that, you can spool code into SQL file as shown in the example in the documentation or play with it in so many different ways. For example, one of the ways is to create an application to manage your APEX component exports (with nice filenames), as shown here

More about that in the next blog post.

Tested in APEX


Friday, June 7, 2019

Username Display Fix

This thing is very simple, but it got me I hope it will help someone.

I was building a small APEX app (in APEX 19.1.*) with a custom authentication scheme (custom plugin) and when I've logged in to the app I've noticed that the username is in lowercase. So the first thing that got to my mind was that there's some problem with my authentication plugin. But that wasn't it.

I'm not 100% sure but I think from APEX 18.1 there's a change how navigation bar looks like. By default when you create an app you'll get username with a nice icon and drop down with Sign Out link. Before, at least in APEX 5.1, by default, there was only a Log Out link. Maybe that's the reason why I didn't notice this thing before.

So, lowercase is actually forced by CSS. So if you want to display your username as it came out from authentication scheme (in my case uppercase) you only need to remove Shared Components > Navigation Bar List > &APP_USER. > List Item CSS Classes property that's by default set to has-username

Tested in APEX


Thursday, May 9, 2019

Generate APEX URL in JavaScript

When developers want to generate APEX URL from a JavaScript the thing that most of them will do is to concatenate URL string like this:

But there's one (unfortunately) undocumented feature that you can use to make it easier. It's possible to do it by using apex.util.makeApplicationUrl function that excepts a JavaScript object as the only parameter. In that object, you can define all that is needed to generate an APEX URL.

Here is an example:

Note: the function will not generate the checksum for pages or items with session state protection turned on.


Tested in APEX