JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Class: viewmodel/js/api/context/ContextualData

Representation of contextual data which can be exchanged between pages during page to page navigation.

Contextual data is typically pair of some data and semantic type of that data. Optionally it can contain also data identifing the calling page.

You will need to create ContextualData when using the Navigation API as most of the API methods accept its instance. To create an instance use static factory methods ContextualData provides:

ContextualData.createBlankPageContext
to create a blank context. You usually open ABCS landing pages with this context.
ContextualData.createStartWithBlankRecordContext
to create a context bound to an entity and possibly initialized with a partial and incomplete data. You usually open ABCS create pages with this context.
ContextualData.createRecordToEditContext
to create a context bound to an entity and initialized with record data. You usually open ABCS edit and detail pages with this context.
Version:
  • 16.3.5
Source:

Methods

(static) createBlankPageContext(inputopt) → {viewmodel/js/api/context/ContextualData}

stable API

Create empty contextual data.

Parameters:
Name Type Attributes Description
input Object <optional>
Properties
Name Type Attributes Default Description
caller String <optional>
activePageId

id of the page which page navigation should allow to return to; optional parameter which fallbacks to activePageId

Version:
  • 16.3.5
Source:
Returns:
Type
viewmodel/js/api/context/ContextualData
Example

Create a blank page context and navigate to an ABCS landing page.

var emptyContext = ContextualData.createBlankPageContext({
    // current page where this data and request originated;
    // by default replaced with the activePageId, if 'caller' not set
    caller: 'customerListPage'
});
// navigate to the landing page
Abcs.Pages().navigateToPage('myLandingPage', emptyContext);

(static) createRecordToEditContext(input) → {viewmodel/js/api/context/ContextualData}

stable API

Create contextual data representing a record which can be edited.

Parameters:
Name Type Description
input Object
Properties
Name Type Attributes Default Description
entityId String

id of the entity which data are being passed

data viewmodel/js/api/Record

record data

caller String <optional>
activePageId

id of the page which page navigation should allow to return to; optional parameter which fallbacks to activePageId as the id of currently open page.

Version:
  • 16.3.5
Source:
Returns:
Type
viewmodel/js/api/context/ContextualData
Example

Get data of currently selected customer from a table and annotate the data with their type (that is 'customer' business object), with their semantic (that is values of an existing single record of the given business object are available and can be manipulated), with source where the data come from (that is current page). Send such data to a different page and let it do something useful with them.

var customerToEdit = ContextualData.createRecordToEditContext({
     // what business object are these data of:
     entityId: 'customer',
     // customersListArchetype is instance of ListArchetype which
     // provides selected customer row
     data: customerListArchetype.getSelectedRecord(),
     // current page where this data and request originated;
     // by default replaced with the activePageId, if 'caller' not set
     caller: 'customerListPage'});
// navigate to the page
Abcs.Pages().navigateToPage('customerEditPage', customerToEdit);

(static) createStartWithBlankRecordContext(input) → {viewmodel/js/api/context/ContextualData}

stable API

Create contextual data representing a blank new record which can be populated and created. If record being created is a child record then reference to parent record should be pre-initialized.

Parameters:
Name Type Description
input Object
Properties
Name Type Attributes Default Description
entityId String

id of the entity which data are being passed

data viewmodel/js/api/Record

record data

caller String <optional>
activePageId

id of the page which page navigation should allow to return to; optional parameter which fallbacks to activePageId as the id of currently open page.

Version:
  • 16.3.5
Source:
Returns:
Type
viewmodel/js/api/context/ContextualData
Example

Creating a new child record in a separate page may require reference to parent record be passed around. For example SparePart business object is child of Product. Initiating creation of new SparePart object spanning multiple pages could look like this:

// productDetailArchetype is DetailArchetype representing existing
// Product record:
var productId = productDetailArchetype.getRecord().getValue('id');
// create blank SpareProduct record with all mandatory parent info:
var blankSparePart = Record.createSimpleRecord({
     // sparePart is child record of product business object and
     // product ID is mandatory for new spare part to be created:
     product: productId});
});
var sparePartToCreate = ContextualData.createStartWithBlankRecordContext({
     // what business object are these data of:
     entityId: 'sparePart',
     // blank or preinitialized spare part data:
     data: blankSparePart,
     // current page where this data and request originated;
     // by default replaced with the activePageId, if 'caller' not set
     caller: 'productDetailPage'});
// navigate to page where spare part is created
Abcs.Pages().navigateToPage('sparePartCreatePage', sparePartToCreate);