Tuesday, January 4, 2011

Missing ID in the No Template Region Template

When you create or edit a region in APEX you can select a template. Region templates define the location of buttons in a region, how the region looks, etc. There is a region template called "No Template" which is the first option in the template list. When you select No Template as the region template APEX will only display the content of the region an nothing else (no header, buttons, etc).


There is a problem with using No Template if you use Dynamic Actions or have any JavaScript code which references the region. The No Template region template does not contain an ID attribute which prevents dynamic actions from binding to the region.

The following steps will create a region that simulates the "No Template" region and includes an ID so it will work with dynamic actions.

- Go to Shared Components
- Click on Templates
- Click the Create button
- Template Type: Region
- Select From Scratch and click Next
- Name: No Template w. ID
  Theme: Select your default theme (in most cases you'll only have one option)
  Template Class: Reports Region
  Click the Create button
- You should be brought back to the Templates page. To filter the list of regions select Region as the Type and click the Go button
- Click on No Template w. ID to modify it
- Put the following HTML in the Definition section


#BODY#
- It should look like
- Click the Apply Changes button

If you modify your region that used No Template and change it to the new template that you created, No Template w. ID, it will look the same for the end users with the big difference being that dynamic actions will work when applied against the region.

The following query identifies regions that use the No Template region template which you may want to modify to use the custom No Template w. ID:

SELECT page_id, page_name, region_name, template
FROM apex_application_page_regions
WHERE application_id = :app_id
AND template = 'No Template'
Note: I think Patrick Wolf mentioned that the No Template region template will include an ID in APEX 4.1.

4 comments:

  1. Nice one Martin.
    However, I hope "No Template" remains completely empty and instead we get a "No Template w/ID" as your posts suggests.
    Sometimes, you need a region to really have no template. :)

    ReplyDelete
  2. Hi Jorge,

    Such a really empty template is also easy to create :-)

    Learco

    ReplyDelete
  3. Thanks, Martin - this had me stumped for a while when I was trying to use a dynamic action to apply styling to a column. I read somewhere that this was the reason, but it is nice to understand properly

    Garth

    ReplyDelete
    Replies
    1. Hi Garth,

      In the latest version of APEX this has changed and now the No Template contains the Static ID if you provide one.

      Martin

      Delete