MAS 9.2 series tutorial
This tutorial walks through the six cases in the order you meet them in an app. It builds on Datasource Basics. We ran every step on our test system, on the MAS 9.2 series, on a page of our Components Explorer. All six datasources read work orders through the object structure mxapiwodetail.

Step 1 · Bind a list, and the datasource loads#
The usual case needs no code at all. A list names a datasource, and the datasource loads when the page draws the list:
<maximo-datasource id="fs_d_load_bound" object-structure="mxapiwodetail"
where="siteid="BEDFORD"" order-by="wonum" page-size="3" selection-mode="none">
<schema id="fs_d_load_bound_s">
<attribute name="wonum" unique-id="true" id="fs_d_load_bound_a_wonum"/>
<attribute name="description" id="fs_d_load_bound_a_description"/>
</schema>
</maximo-datasource>
<data-list id="fs_d_load_bound_list" datasource="fs_d_load_bound" no-select-behavior="true" show-search="false">
<list-item id="fs_d_load_bound_list_item">
<label id="fs_d_load_bound_list_item_t" wrap="true" label="{item.wonum} · {item.description}"/>
</list-item>
</data-list>When the page opened, this datasource sent one request, with the where clause, the order and the two attributes of its schema. The answer counted 1,483 work orders. The request asked for six rows, and page-size says three. Pagination and Performance explains why.
Step 2 · Know which datasources stay silent#
The second datasource of the page has the same declaration, and no list or field reads it. It sent no request when the page opened. Its state read hasData = false with 0 rows.
One detail is worth knowing here. Our page shows the state of every datasource in a label:
<label id="fs_d_load_free_state" label="rows = {fs_d_load_free.state.itemCount} · totalCount = {fs_d_load_free.state.totalCount}"/>That label reads the datasource, and the datasource stayed silent all the same. On our page a binding to state started no load. A list did, and so did a field that binds to item.
So when a datasource stays empty, look first for the component that reads its records. A datasource that only your controller uses has no such component, and the next step is for that case.
Step 3 · Load from code#
A controller gets the datasource by its id and loads it:
const ds = this.page.findDatasource('fs_d_load_free');
await ds.load();Four calls load a datasource, and they differ in when they ask Maximo. We ran each one and counted the requests:
| Call | On a datasource that is loaded |
|---|---|
load() | 0 requests, it keeps the rows it has |
loadIfNecessary() | 0 requests, returns false |
load({noCache: true}) | asks Maximo again |
forceReload() | asks Maximo again |
On a datasource that held no rows yet, load() and loadIfNecessary() each sent one request, and loadIfNecessary() returned true.
load() on a loaded datasource is cheap, so a page can call it every time it opens. To see a change that happened on the server, use forceReload().
loadIfNecessary() starts the load and returns at once. Our line read 0 rows at that moment, and the state of the datasource showed 3 rows a moment later. Use await ds.load() when the next line of your code needs the rows.
Step 4 · Hold a datasource back with can-load#
Some datasources should wait, for example until the user picked a site. The attribute can-load takes a condition:
<state id="fs_d_load_go" name="go" type="boolean" value="false"/>
<maximo-datasource id="fs_d_load_gate" object-structure="mxapiwodetail"
where="siteid="BEDFORD"" order-by="description" page-size="3"
can-load="{page.state.go}" selection-mode="none">This datasource is bound to a list, as in Step 1. With the condition false it sent no request when the page opened. A load() from code sent none either: the call came back with 0 rows and without an error.
Then we set the state to true and waited, and no request went out. Opening the gate allows the load, and it starts none. The next load() sent the request:
this.page.state.go = true;
await this.page.findDatasource('fs_d_load_gate').load();Set the condition and call load() together, in the same handler.
Step 5 · Load early with pre-load#
The opposite wish also exists: a datasource that no component reads, and whose rows your code wants to find loaded. pre-load="true" does that:
<maximo-datasource id="fs_d_load_pre" object-structure="mxapiwodetail"
where="siteid="BEDFORD"" order-by="description desc" page-size="3"
pre-load="true" selection-mode="none">This datasource is bound to nothing, like the one of Step 2. It sent its request when the page opened and held 3 rows of 1,483.
Step 6 · Show one record#
A detail page reads one record. The datasource narrows the where clause to that record and sets page-size="1", and fields bind to item, the current record:
<maximo-datasource id="fs_d_load_one" object-structure="mxapiwodetail"
where="wonum="1221" and siteid="BEDFORD"" page-size="1" selection-mode="none">
<schema id="fs_d_load_one_s">
<attribute name="wonum" unique-id="true" id="fs_d_load_one_a_wonum"/>
<attribute name="description" id="fs_d_load_one_a_description"/>
<attribute name="status" id="fs_d_load_one_a_status"/>
<attribute name="status_description" id="fs_d_load_one_a_status_description"/>
<attribute name="wopriority" id="fs_d_load_one_a_wopriority"/>
</schema>
</maximo-datasource>
<field id="fs_d_load_one_f_num" label="Work order" value="{fs_d_load_one.item.wonum}"/>
<field id="fs_d_load_one_f_status" label="Status" value="{fs_d_load_one.item.status_description}"/>The fields loaded the datasource when the page opened, with oslc.pageSize=1 in the request.
We made one mistake on the way, and it is a common one. Our first schema had status_description and left out status. The status field then drew a striped bar where its value belongs. With status in the schema it read “Approved”. The cookbook recipe Add a Field shows that bar and what it means.
Step 7 · Tell “nothing yet” from “nothing found”#
The fifth datasource of the page asks for a work order number that does not exist. It loaded, and Maximo answered with no rows. On screen its list read “No results found”.
The list of Step 4, behind its closed gate, read “No results found” too. Its datasource had never asked. The two lists look the same, and the state of the datasource tells them apart:
hasData | itemCount | totalCount | |
|---|---|---|---|
| never loaded | false | 0 | 0 |
| loaded, and the query found nothing | true | 0 | 0 |
| loaded | true | the rows it holds | the rows that match in Maximo |
The fourth property is loading. It is true while a request runs, and a label or a loading indicator can bind to it like to any other state. On another page of the explorer we saw it read true while a request for 500 rows with forty attributes ran.
The whole page in the editor#
Our MAF editor shows these states for every datasource of a page in its Data tab. For this page it lists four datasources as loaded, each with its query and its request. The empty one is marked with 0 rows and the note “no rows for this user”. The two silent datasources of Step 2 and Step 4 are in the group “not loaded” below.

What to read next#
Search and Filtering continues with the calls that change what a loaded datasource shows. Maximo-Datasource vs. JSON-Datasource compares the datasource of this page with the one that reads a file of the app.
IBM documents can-load, pre-load and the other attributes of <maximo-datasource> in the product itself. In the Application Configuration application, open the ? menu and choose Component Documentation.
