The Boardwalk Client Virtual Machine - JavaScript (henceforth referred to as the BCVMJS) is a client library that simplifies interaction with the Boardwalk Application Engine. The BCVMJS is designed with following goals in mind:
To summarize, BCVMJS is a stateful client-side SDK that simplifies manipulation of data residing in an Boardwalk Application Engine.
This document will outline concepts and samples of BCVMJS to help a developer use the library in building an application.
Connect with BoardwalkTech Customer Support for downloading the BCVMJS library. Documentation is available at http://bcvmjs-doc.boardwalktech.com .
Firstly, import the BCVMJS into your web page.
<script src="js/bcvm-v2.1.0.js"></script>
Importing the library also initializes it. It creates a local variable bcvm through which the library can be accessed.
To use the library, one must instanciate the Environment object. This object can load multiple grids into the client, provide editors for to manpipulate data, and enable communication with BAE. To initialize an Environment, you need the Credentials for accessing the BAE:
let env = bcvm.Srv().CreateEnvironment({
usr: "username",
membershipId: 1234,
nhPath: "NH_Path",
pwd: "password",
urlPrefix: "http://server.boardwalktech.com/BAE_4_5/rest/v1",
});
Multiple instances of Environment object can be created such that
The library comes with 2 sets of interfaces: one for viewing and one for editing grids. A typical Boardwalk Grid can contain data in the order of millions of cells. Hence the objects for viewing data are optimized for lower memory consumption, and do not support editing of the grid by default. The editor objects must be explicitly created for data manipulation. The key interfaces in this library are:
The following sample creates a Grid with 2 Columns and 5 Rows, and uses loops to initialize the cells to a value:
let ge = env.createGridEditor({
collabId: 1234,
wbId: 4321,
name: "G" + new Date().toISOString(), // to ensure uniqueness in grid name
description: "Test Sample Grid"
});
// insert 2 columns
let ce = null;
ce = ge.insertColumnAtStart("1");
ge.insertColumn("2", ce);
// insert 5 rows
let re = null;
re = ge.insertRowAtStart("1");
re = ge.insertRow("2", re);
re = ge.insertRow("3", re);
re = ge.insertRow("4", re);
ge.insertRow("5", re);
// use loops to initialize values
ge.getRows().forEach((rv, ri) => {
ge.getColumns().forEach((cv, ci) => {
ge.getCellEditorRC(rv.getRowKey(), cv.getColumnKey()).stringValue = ri + " : " + ci;
});
});
// submit to grid
env.submitGrid(ge, { critical: true, criticalLevel: 16 }).then(function (ss) {
console.log("Grid Creation Successful", ss.GridId);
}).catch(function (err) {
console.log("Grid Creation Failed", err);
});
Mostly, the data manipulation may happen on an existing grid. Such a grid must first be loaded into the VM Environment, and then an editor can be used to manipulate that data. The 'Load' process in the VM takes a snapshot of the grid and makes it available in the VM, like caching.
let gridId = 1234567;
env.loadGridById(gridId).then(function () {
console.log("Grid Load Successful", gridId);
// ... manipulate the grid here
});
Below sample creates an editor on an existing grid, already loaded in the Environment.
// create an editor on a grid loaded in the environment
let ge2 = env.getGridEditor(gridId);
// add a row at the end, and update its cells values
let re2 = ge2.insertRowAtEnd("Last Row");
let cells = ge2.cells.getCellsByRowKey(re2.getRowKey());
cells.forEach((lv, li) => {
lv.stringValue = "Last Row " + li;
});
// submit grid
env.submitGrid(ge2, { critical: true, criticalLevel: 16 }).then(function (ss) {
console.log("Grid Updation Successful", ss);
}).catch(function (err) {
console.log("Grid Updation Failure", err);
});
Refer to the documentation of specific modules and classes for more information about methods and behaviors supported in the library. This documentation specifically includes only such elements which are consumed by a third-party user. There are several elements in the library which are for its internal working; the library documentation doesn't cover such elements.
Generated using TypeDoc