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

Class: viewmodel/js/api/PageViewModel

Describes the root top-level ABCS page view model.

Each ABCS page binds its view to an instance of generated PageViewModel representing the root page view model. ABCS uses knockout to bind HTML view t its model.

The model consists of higher constructs such as page Archetypes, Business Objects (Entities) the page works with and generated Business Methods used on the page.

Page view model instance:

  • is accessible as $root context inside the DOM generated for the page
  • passed as self into Custom JS Business Action code blocks
  • passed as params.root into Custom Code component view model
  • 16.3.5

Pass page view model into custom ko component's model

<my-custom-component params="{
    pageViewModel: $root

List page Business Objects in custom component's model

var MyCustomComponentModel = function (params) {
    // params.pageViewModel contains reference to the page view model
    // as the previous example demonstrates
    var pageViewModel = params.pageViewModel;

    // build list of all BO names used on the page
    var entities = pageViewModel.Entities;
    var message = 'Page contains Business Objects: ';
    message = message +
    Object.keys(entities).map(function (entityId) {
        return entities[entityId].getName();
    }).join(', ');

    // set the message into a ko observable to be bindable in your
    // component's HTML view
    this.message = ko.observable(message);


Archetypes :Object.<String, viewmodel/js/api/Archetype>

stable API

Map of all archetypes used on the page identified by their ids.

Note that particular archetypes may not be forever present on a page. As their owner component (such as table, list or a form) may be removed from the page, so may the archetype be removed along with it. Hence you should always check for the archetype's existence before using it.

  • 16.3.5

Entities :Object.<String, entity/js/api/Entity>

stable API

Map of all Business Objects (Entities) used by page archetypes identified by their ids.

  • 16.3.5

Observables :Object.<String, Object>

stable API

Map of all observables objects provided by page archetypes. Contains all objects returned by Archetype.getObservables identified by archetype ids.
So pageViewModel.Observables.customerTableArchetypeId is a shortcut for pageViewModel.Archetypes.customerTableArchetypeId.getObservables.

  • Object.<String, Object>
  • 16.3.5