MAS 9.2 series comparison
This comparison follows the Controller Architecture Overview, which shows all four kinds of controller on one page. We ran every step on our test system, on the MAS 9.2 series, on pages of our Components Explorer.
One for the app, one for each page#
The application names its controller once, and each page names its own. The opening tags, shortened:
<maximo-application controller="AppController" id="FSCOMPM">
<page id="fs_ctl_trace" controller="FsCtlController" title="Controllers: who gets which call">
<page id="fs_ctl_two" controller="FsCtlController" title="Controllers: the second page">Two of our pages name the same class. To see how many objects that makes, the class counts its instances. The part of the class that counts, shortened here:
let instances = 0;
class FsCtlController extends FsExplorerController {
constructor() {
super();
instances += 1;
this.instance = instances;
this.resumes = 0;
}
pageResumed(page) {
const p = page || this.page;
this.resumes += 1;
p.state.visits = (p.state.visits || 0) + 1;
}
}The first page showed instance 1 and the second page showed instance 2. Each page gets an object of its own, also when two pages name one class. A field such as this.resumes therefore belongs to one page.
The application controller exists once. Its first call, applicationInitialized, was the first line of our trace, before any page.

What survives when the user leaves#
We went from the first page to the second, back, and to the second again, and read the line under the trace each time:
| Step | Instance | Visits of that page | Hooks the page controller got |
|---|---|---|---|
| the first page opens | 1 | 1 | pageInitialized, pageResumed |
| the second page opens | 2 | 1 | pageInitialized, pageResumed |
| back to the first page | 1 | 2 | pageResumed |
| the second page again | 2 | 2 | pageResumed |
A page that the user leaves stays alive. Its controller object stayed the same, its fields kept their values, and its page state kept counting. pageInitialized ran once per page, and each return ran pageResumed alone.
So a value in a page controller or in page state is still there when the user comes back. That is useful for a filter the user set. It is a trap for a form: the values of the last visit are still in it, until pageResumed clears them.
Where state lives#
Both controllers reach two stores. page.state belongs to one page. app.state belongs to the application, and every page reads the same values. A button on our pages counts on the application:
ctlCount() {
this.app.state.ctlCount = (this.app.state.ctlCount || 0) + 1;
}We pressed it three times on the first page and opened the second page. The second page read 3. The number of visits, which each page keeps in its own state, read 1 there.
page.state | app.state | |
|---|---|---|
| Who reads it | the page and its controller | every page, every controller |
| How long it lives | as long as the app runs; the page keeps it between visits | as long as the app runs |
| Use it for | what one screen shows: a tab, a filter, a busy flag | what pages share: the record the user picked, a setting |
State Management covers the declaration of state and its bindings.
Who answers a click#
A button names a method, and the two controllers are asked in a fixed order. We gave buttons of the first page four names:
on-click | The method exists on | What ran |
|---|---|---|
ctlPageOnly | the page controller | the page controller |
ctlAppOnly | the application controller | the application controller |
ctlBoth | both | the page controller, then the application controller |
ctlNowhere | none | nothing |
A click goes to the page controller first and then on to the application controller. Each of the two that has the method runs it. So the application controller is the place for a handler that many pages need: write it once there, and a button on any page reaches it.
Note the third row. A method name that exists on both runs twice, once on each. When a page should answer in its own way, give its method a name of its own.
The last row fails in silence. Our MAF editor checks every handler against the controllers of the app and marks the one that no class has. It leaves ctlAppOnly unmarked, because the application controller has that method:

Its finding reads: “No controller of this app has a method ‘ctlNowhere’ for on-click.”
The application controller hears every page#
The page hooks do not end at the page. Our application controller has the three methods too, and it got each of them for every page we opened, right after the page’s own controller:
page.pagePaused(fs_ctl_trace)
app.pagePaused(fs_ctl_trace)
page.pageInitialized(fs_ctl_two)
app.pageInitialized(fs_ctl_two)
page.pageResumed(fs_ctl_two)
app.pageResumed(fs_ctl_two)The hook gets the page as its argument, so one method can serve all pages. In our controller, ctl adds a line to the trace and isCtl picks the pages of this demo:
// AppController
pageResumed(page) {
if (isCtl(page)) ctl(this.app, `app.pageResumed(${page.name})`);
}This is the place for work that belongs to every visit of every page: a check, a log line, a value that each page needs fresh. The application controller got its call also on a page whose own pageResumed threw an error, as Using Lifecycle Hooks Correctly shows.
Which one to use#
| You write | Put it into |
|---|---|
| the handler of a button that exists on one page | the page controller |
| a handler that buttons on several pages share | the application controller |
| the load of a page’s data on each visit | pageResumed of the page controller |
| work for every visit of every page | pageResumed of the application controller |
| setup that the whole app needs once | applicationInitialized of the application controller |
| a value that one screen shows | page.state |
| a value that pages share | app.state |
Start in the page controller. Move a method to the application controller on the day a second page needs it.
What to read next#
Using Lifecycle Hooks Correctly covers what a hook may do and what happens when it takes long or fails. App vs Page vs Datasource Scope covers the same question for datasources: where to declare one, and how code finds it.
IBM documents the attribute controller in the product itself. In the Application Configuration application, open the ? menu and choose Component Documentation for maximo-application and page.
