NTwers
NTwers

Reputation: 188

Change page title based on item in Oracle APEX 4.0

In Oracle APEX 4.0, I have a database of customers and I would like the page title to change to the name of the customer I selected to edit. I entered the title like this: https://i.sstatic.net/Bo0cy.png

However, the tab comes out like this: https://i.sstatic.net/Z41H4.jpg

What am I doing incorrectly?

Upvotes: 2

Views: 14529

Answers (2)

paul
paul

Reputation: 1

declare l_order_id number; begin -- create collections -- apex_collection.CREATE_OR_TRUNCATE_COLLECTION ('CUST_ORDER_ITEMS');

-- Loop through the ORDER collection and insert rows into the Order Line Item table
for i in 1..apex_application.g_f01.count loop
    apex_collection.add_member(
        p_collection_name => 'CUST_ORDER_ITEMS',
        p_c001            => to_number(apex_application.g_f01(i)), -- product_id
        p_c002            => to_number(apex_application.g_f02(i)), -- unit_price
        p_c003            => to_number(apex_application.g_f03(i)),  -- quantity
        p_c004            => apex_application.g_f04(i),  -- desc
        p_c005            => apex_application.g_f05(i)  -- unit
    );
end loop;

end;

Upvotes: 0

Richard Pascual
Richard Pascual

Reputation: 2021

Using a Substitution String to Set Variable Apex Page Properties

This solution was developed on a system hosted by Oracle Corp. at apex.oracle.com, where the APEX (Oracle Application Express) version is currently 4.2.5. Although the OP is requesting advice for release 4.0, the functionality requested has been possible since the late 3.x versions of Apex through to the present.

This solution uses substitution strings. Any application item or page item can be referenced by a substitution string. Any string that begins with an ampersand (&), ends with a dot (.), and contains an item's name (in all capital letters) between them will be interpreted as a substitution string and will be replaced by the item's value in the current session/context.

This is useful because the value of the referenced item can be manipulated through PL/SQL code, SQL queries, and user input.

Substitution String Notation:

You can refer to a page item PX_SAMPLE_ITEM with the substitution string &PX_SAMPLE_ITEM..

It is important to note that the dot at the end is necessary.

Setting a Variable Page Title

This is one place where a variable application ITEM can be set (Page Title Attribute):

Variable Page Title Set Up

The following are a couple of screenshots where I used a page-level item, defined as a variable SELECT LIST form element. The select list item also had a REDIRECT property set so that the page would automatically refresh and update the page title property each time a new value was selected or altered.

Variable Page Title Property Example One

Variable Page Title Property Example Two

Verifying Page Configuration and Settings

If you have any difficulty getting things to work from the first pass when creating the page and its contents, this a summary of the settings to verify:

  1. Note that within the view of the application, PAGE 11 is the page which contains my example of a variable page title value.

Application Layout of Pages

  1. Drill down to the layout properties of page 11. P11_PAGE_TITLE is the bucket that contains whatever you want the page title to be. This can be a static definition, the result of a user selection, etc. Make sure to create this item and use the same name when referencing it within your page title definition section (highlighted in section/step 3 below)

Individual Apex Application Page Definition

  1. Note the circled areas. These are the fields that need the definition/reference of the page item mentioned in step 2 above. The first field, the "page name" is not as important as the second field which is part of the "page display" properties. I filled in both, but you probably only need the latter.

Substitution Value Placement Within Page Attributes

Opening the item help-text for the Display Attributes > Title property, the inline documentation says that whatever is inserted into the TITLE field is put inside the <TITLE></TITLE> block of the rendered page HTML code:

More Page Title Definition Detail: Help Text

An Expanded Discussion on Version Compatibility of this Solution

I cannot speak for sure on the exact version where this approach still works as detailed above. I made a few notes below in response to comments from @MNT, the OP author with respect to keeping their instance and its version of Apex up to date.

No problem @MNT, I mentioned possible compatibility between the method tried in 4.25 (my solution) and 4.00 (your version), but keep in mind, the gap in time between these versions is probably more than two years of upgrades and also a jump between backend databases versions (Oracle 10g to Oracle 11g R1... and even 11g R2) Lots has happened. I suppose that isn't very assuring from your situation, but consider upgrading. All APEX patch and release upgrades are free and it's important to keep up.

Why It's important to keep up your upgrades and patch sets (an example) The hop from 4.20 to 4.25 alone (from my experience) was an arduous one as actual internal columns were dropped and index keys disappeared... rendering my repository of exported scripts useless. Make sure you leave yourself a back door or a sound upgrade plan (if you have existing applications) for that kind of event. Once you upgrade, there really is no going back :(

Upvotes: 2

Related Questions