Technically, no - page 0 does not support branches. But how many times do you wish it did?
This scenario recently came up: I wanted to put a "Search" box on every page in my application, so no matter where a user is, they can search the site. Currently, it has 10 or so pages, but this will grow to closer to 50 by production.
So, thought #1 was to put an text item on Page 0, call it search, and then ensure that each and every page had some sort of Branch to run the search. Not so fun, as this was a tedious task, even for just 10 pages. And each time a new page was added to the application - by myself or anyone else - the search branch would have to be added to the page. Clearly not a scalable solution.
With a little bit of help from Raj from the ApEx team, I came up with this solution:
- Create Page 0, if you haven't already
- On page 0, create an item of type "Text Field (Always submits when enter pressed)" - this will let the user type in a search term and press return and fire off the search, as opposed to having to rely on a button being clicked
- Create an Application Process (Shared Components > Application Processes)
- Give it an unusually high Sequence number, such as 999999, as you want it to fire after ALL other page-level processes in your application
- For the source, enter the following, making sure to use the page number that you want your search to branch to:
htmldb_application.g_unrecoverable_error := true;
- Put a condition on the Process to only fire when the REQUEST = P0_SEARCH, where P0_SEARCH is the name of your Search text item on Page 0
- Run your application and test it out
For example, I am using this method to first determine what level of access a user has. If they have Access Level A, then they branch to page 1; otherwise, they branch to page 10. Sure, I could accomplish this at the page level with two branches, but I need this functionality to be available application-wide. Thus, this solution saves me countless hours and some of my sanity.