↓ Skip to main content
A rugged pixel-art tablet opened in cross-section, its layers nested one inside the next down to a single chip, cabled to a server

Anatomy of a Maximo Mobile App

You can know where every file in a Maximo Mobile app lives and still have no idea what the app is. That gap produces the expensive surprises: the save that works in preview and fails on the device, the record the search cannot find, the customization that runs twice. All three of them are anatomy problems, and all three are cheaper to avoid than to find.

MAS 9.2 series framework 3.2.8xx

This is a companion to Understanding Your First Maximo Mobile App. That post is the map: which folder holds what, and which file you open. This post is the cross-section, and it answers the question that people get stuck on after a week. What are the parts, what does each part own, and what happens between the finger and the database?

The patterns come from the apps that IBM ships in the 9.2 series, against a framework in the 3.2.8xx line, and from our own apps in the preview of our MAF editor. Where a command can show you a fact on your own install, it is printed beside it, so you can disagree with us using your own system.

Treat every detail on this page as a snapshot. IBM ships a point release about every month, so the version strings move and the source files change with them. The architecture is what lasts. When you need an exact version, read it from your own system.

The specimen
#

TIMESHEET is the smallest app in the shipped set, which makes it the right thing to dissect. TECHMOBILE is the one you will be paid to change. Both are the same kind of object, and the only difference between them is size.

TIMESHEETTECHMOBILE
src/app.xmla few dozen linesthousands of lines
MAML page files under src/maml/twoabout a dozen
JavaScript and JSX files under src/under tenwell over a hundred
Routes in build.jsononea handful
Launch contexts in build.jsonnonea few

Taken from the 9.2 series. The shape of the table is the part that lasts.

TIMESHEET also carries a long src/i18n/labels.json for an app with two screens. That file is generated and inherited, so it says nothing about the size of the app.

The structure is the same at both ends, and that is the reason to start with the small one.

Five layers, and you author one of them
#

A Maximo Mobile app is a document in an iframe, inside a web shell, inside a Cordova activity, inside an Android package, and the server sits below all of it.

d2 diagram d2 diagram

Five layers between the Android package and your page. You author one of them.

Three things follow from that picture, and each one explains a class of bug.

Your app shares the WebView of the frame above it. It runs in an iframe inside NAVIGATOR, and it copies the parent frame’s native objects into its own window. Five of them come down that way: cordova, WL, maximomobile, nfc and WkWebView. The copy runs only when the window differs from its parent. Every layer is served from the same origin, which is what makes the copy legal. So a device-only failure can sit entirely outside your code. When the parent frame did not hand something down, you do not have it.

NAVIGATOR arrives from the server like any other app. It is downloaded on sync and it carries its own version. The shell your app runs inside can therefore be a different build from the shell you tested against. The shipped set has two shells, both declared with type="shell": NAVIGATOR for the device and MANAGE-SHELL for the browser.

The sync engine belongs to the container. It moves data while your app is closed, so your controllers see the results and never the work itself.

The device layer deserves its own treatment, and that is what the runtime section is for.

The parts
#

Inside layer five an app is made of seven kinds of thing, and six of them are files. The seventh is a runtime object that you never declare anywhere in the markup.

The manifest
#

src/app.xml names the app, holds application-scoped state and lookups, declares the navigation menu, and lists the pages by file reference. On a mobile app its root element carries attributes you will not find on other MAF apps.

<maximo-application id="fitools"
                    mas-id="manage"
                    theme="touch"
                    navigator-tile-order="700"
                    default-log-level="error">
  <!-- ... -->
</maximo-application>

navigator-tile-order sets the position of your tile on the NAVIGATOR home screen. It has meaning only inside NAVIGATOR, which makes it a useful thing to grep for. Many of the shipped mobile apps declare it.

Pages
#

There is one MAML file per screen, and each one is a complete <page> document that carries its own state, its own datasources, its controller reference and its whole UI tree. TECHMOBILE keeps about a dozen of them under src/maml/.

Datasources
#

This is the part that people underestimate, because a datasource is a bound, observable collection with a schema, and the schema is where the real declaration happens.

<maximo-datasource id="assetListDS"
                   object-structure="mxapiasset"
                   id-attribute="assetnum"
                   saved-query="MYASSETS"
                   offline-immediate-download="true"
                   mobile-server-search="true"
                   page-size="25">
  <schema id="sch_asset">
    <attribute name="assetnum"    unique-id="true" searchable="true"/>
    <attribute name="description" searchable="true"/>
    <attribute name="status"      filterable="true" sortable="true"/>
    <attribute name="location.description--locdesc"/>
  </schema>
</maximo-datasource>

Two things in that block deserve a closer look, and both of them cost people an afternoon. The -- in the last attribute is an alias across a relationship, and the aliasing matters more than it looks, because an unaliased relationship path in a searchable attribute changes how the offline search runs. The second thing is that searchable belongs to the schema and not to the screen. What a search box searches is fixed when you build the app, and the user typing has no say in it.

Datasource overrides
#

A sibling element reuses a parent datasource’s schema and changes only the query.

<maximo-datasource id="openAssetsDS" ... >
  <schema id="sch_asset"> ... </schema>
  <maximo-datasource-override id="retiredAssetsDS" saved-query="RETIRED" page-size="25"/>
</maximo-datasource>

This is the idiom behind almost every dropdown that appears to swap datasets. It is also a trap when you go looking for the place a datasource was declared, because an override is a second declaring element and a grep for <maximo-datasource walks past it.

Controllers
#

Controllers are plain JavaScript classes, resolved by name from the markup. A page controller handles the UI intent and a datasource controller handles the data lifecycle. They are separate files for a good reason, so keep them separate.

export default class AssetListPageController {
  pageInitialized(page, app) {
    this.page = page;
    this.app = app;
  }

  openAsset(item) {
    this.app.setCurrentPage({
      name: 'assetdetails',
      resetScroll: true,
      params: { assetnum: item.assetnum },
    });
  }
}

Labels
#

src/i18n/labels.json is generated, and hand-editing it is wasted work. TIMESHEET’s copy is long for an app with two screens, because it inherits the messages of the shared library together with its own.

npx @maximo/maxdev-cli localize -i ./src/app.xml -o ./src/i18n/labels.json --format json

The build manifest
#

build.json is the file the shell reads; the framework leaves it alone. Compare what a mobile app declares in it against what a web app declares, and the mobile-only surface falls out on its own.

Read on a 9.2-series install. The values move with every point release; the shape of the table is the part that lasts.

build.json keyMobile app (TECHMOBILE)Web app (OPDASHBOARD)
routesfilledempty
contextsfilledempty
propertiesfilledempty
hasMapPreloadtruefalse
navigatorTileOrdersetabsent
mapMaxNumberTilesPreloadsetabsent
mobileVersionsetabsent
winShell / winZipVersionpresentabsent
comm -3 <(jq -r 'keys[]' IBM-MAF-Apps/TECHMOBILE/build.json   | sort) \
        <(jq -r 'keys[]' IBM-MAF-Apps/OPDASHBOARD/build.json | sort)

Read that table in two halves, because the two halves mean different things. The first four keys exist on both apps and sit empty or false on the web one. The last four are absent from the web app’s file, and those four are the only keys that separate the two build manifests structurally. Every one of them is a message to a shell: the tile position, the map tiles to pre-download, the mobile build number, the Windows packaging. The framework owns none of it, and the container owns all of it.

One tap, end to end
#

Now the same anatomy as a path instead of a stack. A technician taps a row in a list, and the detail screen opens with data in it.

d2 diagram d2 diagram

What happens between the finger and the data. The adapter fork has three outcomes, and your markup picks none of them.

Here is the browser branch at work. A page of our Components Explorer, a mobile app, runs in the browser preview of our MAF editor. The Data tab shows each datasource’s request as a live OSLC GET to the server, with the rows it brought back. On a device the same page would read its local store, and the editor’s offline settings list what a device would hold.

The MAF editor with a phone preview of the page “Datasources: a parent and its child” on the left, showing a list of pumps. On the right the Data tab lists two datasources: fs_c_ds_assets, loaded with 4 rows, and its request GET /maximo/oslc/os/mxapiasset with status 200; fs_c_ds_meters, loaded with 2 rows, and its request to the assetmeter relationship of the current asset. Below, the offline settings of the page’s datasources.
A mobile app in the browser preview takes the online branch: every datasource reads with a live OSLC request, in the Data tab of our MAF editor

Nothing in your markup or your controllers changes between those three branches. That is the whole point, and it is also the single biggest source of “works on my machine” in this framework.

The two forks that make an app mobile
#

Strip everything else away, and a Maximo Mobile app differs from any other MAF app in exactly two places. Both of them are visible in the shipped set, and both are worth checking on an app you inherit.

Fork one: the data adapter
#

The adapter is chosen by a method on the platform object, newMaximoDataAdapter. In the browser it returns a RESTDataAdapter, so every read and write goes to the server. On a device the same method does something more interesting, and the order of its three outcomes is worth knowing by heart.

  1. The datasource declares a service, and then the adapter is a RESTDataAdapter and the datasource is online-only on the device as well. A service has no object structure behind it, so there is nothing for the framework to store locally. This is the one case where a single attribute in your MAML opts a datasource out of offline entirely.
  2. The app runs in an iframe whose parent window has a DataAdapterManager, and then the call is delegated to that parent, which on a device is NAVIGATOR. Your app asks the shell for its data layer, and the shell hands one over.
  3. Otherwise the platform builds its own DisconnectedDataAdapter, so reads come out of the local store and writes become queued transactions.

They are different classes and configuration cannot bridge them, so the consequences show up in behaviour.

  • A write returns a local echo, so controller logic that branches on the server’s answer is branching on a guess.
  • A new record gets a temporary identifier until sync, so reading its href straight after create gives you a value that will change.
  • Deleting a top-level record and creating more than one top-level record are both rejected on the device, and both work in preview.

Designing for this from the start is unremarkable, and discovering it during user acceptance testing is a rewrite.

One more thing sits in the same area and catches people out in preview. When the build target is maximoMobile and the app is served from an ordinary http://localhost URL, the framework logs a warning, rewrites the platform option to browser, and hands back a BrowserPlatform. The mobile platform is selected only when the user agent carries MaximoMobile/ or the URL begins with com.ibm.iot.maximo.mobile. So a browser preview of a mobile app exercises the online path, as the picture above shows, and the offline stack you care about never loads. Sign a mobile app off on a device or an emulator.

Fork two: the shell
#

The second fork is a single key in package.json, which the build reads before it compiles a line of your markup.

{
  "graphite": {
    "platform": "maximoMobile"
  }
}

That key is the switch that selects the stricter build target, and MAML which compiles cleanly for a browser can still fail against it. The key also splits IBM’s own apps into two groups.

for a in IBM-MAF-Apps/*/; do
  printf '%s %s\n' "$(basename "$a")" \
    "$(jq -r '.graphite.platform // "(absent)"' "$a/package.json")"
done | sort -k2

A minority of the shipped apps declare maximoMobile, the others omit the key, and there is no third value anywhere in the set. The split has held across the 9.2 series so far.

The same split shows up in the markup, and that is where it becomes concrete. We compared the element use across all the mobile apps and all the web apps of a 9.2-series install:

Element or attributeMobile appsWeb apps
<table>nevercommon
<dashboard-view>neverused
<chart>neverused
<card-group>usedused more often
<data-list>the main list idiomused less often
mobile-qbe-filtermost appsnever
mobile-server-searchabout half of the appsnever
offline-immediate-downloadmost appsa few apps

<table> never appears in a mobile app, and most web apps use it. Cards go the other way from what most people assume: web apps use <card-group> more often than mobile apps do. The mobile idiom is <data-list>, together with the absence of the table.

One negative result that is still useful. lookup-data="true" puts an object into the preload database, which is a purely mobile mechanism. It appeared in most of the mobile apps and in many of the web apps, so it discriminates badly. When you audit an app to work out what it downloads on the first sync, this attribute tells you less than you would hope.

Where your changes go
#

The last part of the anatomy sits outside the app. When the markup names a handler, the framework walks a chain to find it.

d2 diagram d2 diagram

Every matching handler runs, and the return value threads through all of them.

The important property is written on that arrow. The chain does not stop at the first match. Every controller with a matching method runs, in order, and the running return value is passed through as the last argument.

So AppCustomizations.js is a decorator that adds your behaviour and leaves IBM’s in place. Define saveWorkLog there while IBM’s page controller already has a saveWorkLog, and you have added your logic after theirs, and both of them run. To really intercept the call, give your method a different name, point the markup at your name, and delegate on purpose.

export default class AppCustomizations {
  // Wired from your customized markup as on-click="saveWorkLogChecked".
  saveWorkLogChecked(evt) {
    const ds = this.app.currentPage.datasources.woWorklogDS;
    if (!ds.item.description) {
      this.app.toast('A description is required before saving.', 'error');
      return;                                         // IBM's handler stays out of it
    }
    return this.callController('saveWorkLog', evt);    // explicit delegation
  }
}

Redefine IBM’s method name and you get both behaviours and a bug report. Rename and delegate, and you get a clean seam.

Version skew is the background condition
#

One more fact belongs in an anatomy, because it governs every number above. A single install ships apps that were built against several framework versions at once.

This section is the sharpest snapshot on the page. The spread is the finding, and the exact builds will differ on your install.

for a in IBM-MAF-Apps/*/; do
  printf '%s %s\n' "$(basename "$a")" \
    "$(jq -r '[.dependencies,.devDependencies] | add | ."@maximo/app-processor" // "(none)"' "$a/package.json")"
done | sort -k2

When we ran that on a 9.2-series system, most of the apps declared one and the same @maximo/app-processor build in the 3.2.8xx line. A few declared something older, spread back through the 3.2.7xx, 3.2.6xx and 3.2.4xx lines: GUESTUSER, GUESTLOGIN, COMMONLIB, AIASSISTANT, SELFSERVE, SERVICEOFFERINGS and SOFTWARETRACKING. LOGIN declared no framework dependency at all. The framework packages installed on that same environment reported yet another 3.2.8xx build, a few builds behind the one the apps ask for.

This is why an app is only valid against the release that it was downloaded against. Build it against another one and it compiles clean, and then it misbehaves on the server with no loud failure anywhere. Check what your own app declares before you match anything here to it.

What to read next#

The companion post, Anatomy of a MAF Web App, takes the same cross-section through the other build target, where the layers below the browser fall away and MANAGE-SHELL takes the place of NAVIGATOR.

For the folder map instead of the layer stack, start with Understanding Your First Maximo Mobile App. For the file at the root of it all, read Understanding app.xml.


IBM’s own reference for the elements named here ships with every MAS install and almost nobody finds it. In the Application Configuration application, open the ? menu and choose Developer Documentation and Component Documentation. The product documentation for Maximo Manage is at ibm.com/docs.