↓ Skip to main content
Four upright glass panes in a row, each carrying one simple screen shape, with a ribbon threading through them

Pages and Navigation

Your app has a second screen. Now you need to know what a page really is, how the user gets to it, and what arrives on the other side. The framework answers all three, and its answers are simpler than the published advice suggests. Four of the things everybody repeats about navigation turn out to disagree with the apps IBM ships.

MAS 9.2 series framework 3.2.8xx four ways to change page

Understanding app.xml covered the root and its sections, and it left the <pages> section as a list of names. This post opens one of those names. It stays inside a single app, which is where nearly all of your navigation code will live. Jumps between applications and deep links from outside get one paragraph each at the end, with a pointer to the post that takes them properly.

The patterns come from the apps that IBM ships with a 9.2-series install, in their MAML and their controllers, with pages held in maml/ fragments counted along with the ones in app.xml. The demonstration runs in our Components Explorer, a small Maximo Mobile app we built for these articles, in the preview of our MAF editor. Details move with each release, and the shape holds.

What a page is
#

A page is a non-visual element that owns one screen, and it declares who controls that screen, what it is called, and where its markup lives. Everything the user sees is a child of it. The two build targets carry pages unevenly. The mobile apps hold noticeably more pages each than the web apps.

That difference is worth holding on to. A Maximo Mobile app is usually a deeper stack of small screens, because a phone shows one thing at a time, while a web app spreads the same work across fewer and denser pages.

Here is what the shipped apps actually declare on a page.

Across every <page> element in the apps of the 9.2 series, from the most used attribute to the least used.

AttributeWhat it does
idthe page name, required, unique across every file in the project
controllerthe class that handles this page’s events and lifecycle
titlethe page title, localizable
paddingthe standard eight pixels of content padding, on by default
pathdocumented as not used, see below
filekeeps the page’s markup in its own file
disable-page-reloadskips the confirm dialog on reload
iconan icon for the page, mobile apps only
clear-stackempties the page stack when this page opens
context-idsent in API headers, so a request can be traced to a page

Every page carries an id, and nearly every page names a controller. The other attributes appear in only some of the pages and apps.

id is the one that matters most, and it is the one people trip over. It is the name you navigate to, and the reference is explicit that it has to be unique across every XML file in the project. The build flattens all of those files into one bundle, so two pages called details in two different page files collide, and the build stops.

controller points at the class that runs the screen. A few pages in the corpus declare no controller, which is fine for a screen that only displays static markup.

The first surprise: path is documented as unused
#

The component reference gives <page> a path attribute and describes it in two words: Not used. It says the same about name. Then a good number of apps set path on their pages, usually to something that looks like a route, and the odd app sets name.

We read the reference as correct here, because a route that the framework ignores still documents intent. Treat path as a comment that happens to be an attribute. Write it if you like the way it reads in a long app.xml. Never build anything that depends on it, and never expect a URL to match it.

The second surprise: page-level permissions are documented and unused
#

<page> also carries sigoption and license, and the reference is specific about both. If the user lacks the security option or the license, navigation to that page is blocked. It is exactly the guard you would want for a create screen or a licensed feature.

No shipped app uses either one, and a grep over every page element in the corpus returns nothing at all.

rg -c '<page[^>]*\s(sigoption|license)=' */src -g '*.xml'

What the apps do instead is gate the way in. A <menu-item> takes the same sigoption attribute, and a few apps use it on a number of menu items, mostly to hide a create action from users who may create nothing. The page stays reachable in principle and the door to it disappears.

Both guards are worth knowing. The menu gate is the one with a track record, and the page gate is the one with better coverage, since it also catches a navigation call from your own controller code. No use at all means IBM never shipped one, and it says nothing about whether the framework honours it.

The page stack
#

The framework keeps a flat collection of pages and a stack of the names you have visited. Forward navigation pushes a name onto the stack, and going back pops one off. There is a second, parallel stack holding the parameters each page was given, which matters more than it sounds and comes up again below.

One detail explains a lot of the API. In maximo-js-api the application is itself a page, and that is why setCurrentPage is available on this.app in every controller you write.

d2 diagram d2 diagram

The application is a page that holds pages. Three doors go forward and one comes back.

A page may empty the stack when it opens, with clear-stack. Top-level navigation pages do this on their own, so the attribute exists for the unusual case where a page deeper in the tree has to become a new root. The shipped apps almost never set it, which is a fair measure of how rarely you need it.

Four ways to change page
#

One: the page attribute
#

The simplest move needs no code. A <menu-item>, a <button> and several other elements take a page attribute, and a tap goes there.

<menu-item id="mi_assets" page="fitAssetList" label="Assets" icon="carbon:asset"/>

Many of these sit in the shipped apps. Every mobile app uses at least one, because the navigation menu is built from them.

Two: the change-page event
#

The framework also ships a system event for this. You write on-click="change-page" and pass the target and its parameters as the argument, which gets you parameters without writing a controller method.

It is documented, it works, and almost nobody uses it. Only a couple of apps in the whole corpus do, and nearly all of the uses sit in one web app. Treat it as a curiosity you may meet in somebody else’s code.

Three: setCurrentPage in a controller
#

This is the real answer, and the shipped code settles it: most of the apps call setCurrentPage, many times over.

handleAssetTap(item) {
  if (item && item.href) {
    this.app.setCurrentPage({
      name: "fitAssetDetails",
      resetScroll: true,
      params: { href: item.href, assetnum: item.assetnum, siteid: item.siteid },
    });
  }
}

You reach for the controller when the move needs a decision first. A guard against a missing record, a save before leaving, a different target depending on status: all of them need code, and once you are writing code the attribute buys you nothing.

The guard in that example is worth copying. A tap on a map pin or an empty list row can arrive with nothing useful in item, and a navigation call with no identifier opens a detail page that loads forever.

Four: back
#

Back is where the published advice and the shipped corpus part company, so it gets its own section.

Why almost nobody uses the framework’s back button
#

The framework provides navigateBack(), which reads the page stack, finds the previous entry, and goes there. It is one line, and it handles the empty-stack case on its own by falling back to the default page.

Only a few apps call it, and only now and then, while most apps call setCurrentPage constantly, and a good share of those calls are going backwards to a list the user came from.

The reason is the way navigateBack decides which parameters the previous page receives. By default it hands the previous page the current page’s parameters. The parallel stack holds what that page was originally given, and the framework only restores it when you pass keepCurrentParams: false in the options.

So a plain navigateBack() from a detail screen sends the detail screen’s href back to the list. A list page that reads page.params.href then loads the wrong thing, and the symptom appears one screen away from the call that caused it.

Which parameters the list page receives after navigateBack Which parameters the list page receives after navigateBack
Which parameters the list page receives after navigateBack

An explicit setCurrentPage with the parameters spelled out has no such surprise, which is why the corpus is full of them.

Both are correct tools once you know that. Use navigateBack({ keepCurrentParams: false }) when the previous page should wake up as it was. Use an explicit call when the list needs something new from you, such as a flag saying the record changed and the list should reload.

The back chevron is a mobile thing
#

The other half of back is the button itself, and it splits cleanly by target. The header carries an icon-action attribute that wires its icon to a controller method. Those sit only in mobile apps, and the web apps have none between them.

rg -l 'icon-action=' */src -g '*.xml'
rg -l '<breadcrumbs' */src -g '*.xml'

The web apps navigate back through breadcrumbs instead. Only web apps use the <breadcrumbs> element, so the two lists have no app in common.

That split is a layout decision, and the framework permits either one on either target. A phone header has room for one chevron and a title, and a browser page has room for a trail. It also means a back pattern copied from a web app will look wrong on a phone, and a chevron copied the other way leaves a web user without the trail they expect.

What travels with you
#

Parameters are how a target page learns what to show. They are a plain object, they arrive as page.params, and a few conventions decide whether the target works.

href is the one that matters. It is the REST URL of the record, so the detail page can load exactly that record without building a query. Many of the navigation calls in the corpus carry it, and it is the first thing to reach for.

Carry siteid with any site-scoped key. Most Maximo keys are unique within one site, and two sites may hold the same key. A work order number without its site can open the wrong record, quietly, on a multi-site install.

resetScroll: true on a forward move. Without it the detail page can open halfway down. It appears on many calls, and nearly all of them are in mobile apps, which is where a stale scroll position is most visible.

Pass identifiers, never records. Send the href and the key, and let the target page load its own data. Large objects in parameters survive navigation badly and they hide where the data came from.

One guard to know about: the framework is careful with a move to the page you are already on. In the 3.2.8xx line it compares the page name alone, logs that it is ignoring the change and stays. Later in the 9.2 series the comparison also looks at the parameters. We tried that in our explorer on a later release. A move to the open detail page with a new record changed the page’s parameters, and a label bound to page.params.wonum still showed the old record. The same move through the list page showed the new one. So the bounce through a second page, which older apps use to re-enter a detail screen, still does its job.

Navigation is also where unsaved work gets caught. Before the page changes, the framework asks its changes manager whether anything is tracked and dirty, and a confirm dialog can stop the move. You get that for free on every route above, which is a good reason to change page through the framework instead of manipulating state by hand.

A page pair, end to end
#

Both fragments below are ours, with names that appear in none of the shipped apps.

<page id="fitAssetDetails" title="Asset"
      controller="./controllers/pages/AssetDetailsPageController">

  <header-template id="fit_hdr"
                   title="{page.params.assetnum}"
                   hide-breadcrumb="true"
                   icon-name="carbon:chevron--left"
                   icon-action="returnToList"/>

  <box id="bx_row" direction="column">
    <label id="lb_assetnum" label="{fit_assetDetailDS.item.assetnum}" theme="16-bold"/>
  </box>

</page>
// the list page's controller
handleAssetTap(item) {
  if (item && item.href) {
    this.app.setCurrentPage({
      name: "fitAssetDetails",
      resetScroll: true,
      params: { href: item.href, assetnum: item.assetnum, siteid: item.siteid },
    });
  }
}

// the detail page's controller, wired to the chevron
returnToList() {
  this.app.setCurrentPage({
    name: "fitAssetList",
    params: { reload: this.recordChanged },
  });
}

The same pair runs in our Components Explorer, on demo work orders. The list is scrolled down when WO-1006 is tapped, and the detail page opens at the top with the identifiers in page.params. The chevron in its header calls returnToList, which goes back by name with reload: true. The list page reads that parameter in pageResumed, loads its datasource again and counts the reload in a label.

Three phone frames of Maximo Mobile. First, “Navigation: the list”, scrolled so that WO-1002 is the top row. Second, after a tap on WO-1006, the detail page with WO-1006 as its title and the work order, description and status read from page.params. Third, after a tap on the header chevron, the list again, at the top, with the line “The list was reloaded 1 time(s) after a return.”
List, detail and back by name with a reload flag, in Maximo Mobile on a phone, in the preview of our MAF editor

Read the pair together and the whole model is there. The list decides, passes an identifier, and resets the scroll, while the header wires a chevron to a method. The method goes back by name and hands the list one fact it could not know on its own.

Two doors this post leaves closed
#

Jumping to another application. An app can send the user into a different Maximo application and offer a way back, through the AppSwitcher and its gotoApplication call. A fair number of apps do it, and the shape of the call, the return breadcrumb and the options that control embedding are a subject of their own.

Arriving from somewhere else entirely. A notification, a shared link or another app can land a user directly on a record page, through the <launch-contexts> section that Understanding app.xml describes at the root. The declaration lives in the app being opened, which is the single most confusing thing about it.

Both belong to the detailed navigation post later in this level.

What to read next#

The next posts in this level open what a page holds: Datasource Basics, then Controller Basics, then State Management. For the whole application as one object, read Anatomy of a Maximo Mobile App. For the root that lists these pages, read Understanding app.xml.


IBM’s own reference for <page>, <menu-item> and the header template ships with every MAS install. In the Application Configuration application, open the ? menu and choose Component Documentation. The path and name descriptions quoted above are its own words.