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