MicroStrategy ONE

Model Blocks

The Block Infrastructure is based on the Model-View-Controller architectural pattern. This topic discusses the salient features of model blocks (also called models).

A model is a data structure with no visible GUI. In the context of MicroStrategy Web’s Block Infrastructure, it is a block which contains a collection of "properties" (that is, name-value pairs called block properties). This in-memory block is converted to JavaScript Object Notation (JSON), and this JSON is converted to a JavaScript object on the client-side.

Models can be nested. In other words, a property of a model can be set to some other model.

As explained in the Block Library topic, new blocks are created using server-side layout definition files by instantiating blocks from the Block Library and setting the properties on them.

Every model block instantiated on the Prompt page gets registered with a single global JavaScript Factory object (mstr.controllers.Factory). Typically the model block is passed to the Factory as JSON, which the Factory then instantiates into an actual model. The Factory looks for a scriptClass property value in the JSON.  If found, the Factory instantiates that class. For implementation details, see Registering the Model Block with the Factory.

Every registered model receives an “id” for later reference. The Factory object looks for an "id" property value in the model's collection of properties. If it cannot find the “id”, a new “id” is assigned automatically, and a handle to the model gets stored in a lookup table within the Factory.

An event can be triggered if there’s any change in a model’s property. It is possible for views to subscribe to such events. This cross-object communication is handled by the global JavaScript EventManager object (mstr.controllers.EventManager) in conjunction with the Factory JavaScript object. See Models, Views and Events for details.