Change page title based on item in Oracle APEX 4.0
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):
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.
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:
- Note that within the view of the application,
PAGE 11
is the page which contains my example of a variable page title value.
- 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)
- 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.
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:
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 :(
NTwers
Updated on August 04, 2022Comments
-
NTwers over 1 year
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: http://i.stack.imgur.com/Bo0cy.png
However, the tab comes out like this: http://i.stack.imgur.com/Z41H4.jpg
What am I doing incorrectly?
-
NTwers almost 10 yearsTake a look at this page: Page Property Defined in Oracle Apex Does Not Display by @RichardPascual . This may help you with the error you're getting.
-
-
NTwers almost 10 yearsI tried what you suggested, but it doesn't work. And I made sure to put in the ampersand and dot.
-
Richard Pascual almost 10 yearsOk, I added a few more screenshots to show where to validate the settings. If you are not able to verify your own settings or resolve the differences, some descriptive detail (or screenshots) of the output you are getting will guide the remaining steps of this solution.
-
NTwers almost 10 yearsI appreciate the work you put into this. I followed the instructions you posted here, but I can't seem to get it to work. Perhaps this is something that is only possible in later versions.
-
Richard Pascual almost 10 yearsThanks, @MNT, I appended a response at the bottom of this solution since it has important considerations other readers will want to know. If you're stuck in 4.0, there are probably still other creative avenues for accomplishing your intended task.
-
NTwers almost 10 yearsYou mentioned in the beginning that "the functionality requested has been possible since the late 3.x versions of Apex through to the present." If I'm using 4.0, it should be possible.
-
Richard Pascual almost 10 yearsYou may be encountering template problems/issues.
TITLE
is a value assigned and tracked by Apex, but eventually, the application depends on the accuracy of the output templates defined for the user's view. I kicked off a new SO question in case there is interest in validating what I have said (and observed in the past) and some of the more prominent possibilities. Again, if you're interested in more accurate answers to your specific situation, more detail about the output received would be a good assist in producing quality answers. -
Richard Pascual almost 10 yearsThe post: Page Property Defined in Oracle Apex Does Not Display. See if it fills in any blanks.
-
NTwers almost 10 yearsI added links to the images that display what I did and the result I get. I read your post and I'm getting similar errors, but I checked the template that I'm using and everything matches what you have on that post. My template has the title line, but I still get the result that you said would happen if the title line was not there.
-
Richard Pascual almost 10 yearsThe screenshots @MNT added look good. Make sure your page item
P2_PAGE_TITLE
(if you made it a select-box like mine) is set to "Redirect and Assign Value to Item" (this is important). I noticed that using other form elements to set the page item value needed an additional push... to either refresh the page (or redirect back to it) AND carry forward the value set toP2_PAGE_TITLE
so that it sets the page value to that value when it is reloaded. -
NTwers almost 10 yearsI am not using a select list. I am using a Display Only item. So there is no option of "Redirect and Assign Value to Item".
-
Richard Pascual almost 10 yearsCheck out the alternate post I set up recently: Page Property Defined in Oracle Apex Does Not Display. There is an edit at the bottom with guidelines based on additional detail about the OP. This concept can work also as a part of a
Display Only
item as shown in the screen-caps with a little additional work. -
NTwers almost 10 yearsI was able to figure out how to have the information display properly, with much assistance from @RichardPascual. I created a computation on the page that I wanted to display tab information. The computation is a SQL query with a computation point before the header. Thank you for all the effort you have been putting into this question to help me and others who are encountering the same issues. Your efforts are greatly appreciated.