Caplin Trader 5.1.0

Class: module:br-presenter/PresentationModel

module:br-presenter/PresentationModel()

The PresentationModel is used to transform a set of domain models into a form that is tightly aligned with the view that will be used to display and edit those domain models. As a consequence, the view becomes free of all logic, and components can be tested through the presentation model rather than using brittle, click-based testing via the view.

Presentation models are built as a tree of module:br-presenter/node/PresentationNode instances, where the root node must extend PresentationModel, which in turn extends module:br-presenter/node/PresentationNode.

Constructor

new module:br-presenter/PresentationModel()

PresentationModel is an abstract base class that all presentation models must extend, and so is not constructed directly.

Extends:

Extends

Methods

getClassName()

Returns the presentation model class name.

Returns:

Presentation model class name.

getComponentFrame()

Presentation models can use this method to receive a reference to the frame containing the module:br-presenter/component/PresenterComponent that this model resides within.

getPath()

Returns the path that would be required to bind this node from the view.

This method is used internally, but might also be useful in allowing the dynamic construction of views for arbitrary presentation models.

Inherited From:

nodes(sNodeName, vProperties)

Returns all nested nodes matching the search criteria reachable from this node.

Care is taken not to search up the tree in cyclic presentation models (where some of the presentation nodes have back references to presentation nodes higher up in the tree).

Parameters:
Name Type Description
sNodeName String

The name of nodes to match.

vProperties Object

Only nodes having this array or map of properties will be matched.

Inherited From:
See:

properties(sPropertyName, vValue)

Returns all nested properties matching the search criteria reachable from this node.

Care is taken not to search up the tree in cyclic presentation models (where some of the presentation nodes have back references to presentation nodes higher up in the tree).

Parameters:
Name Type Description
sPropertyName String

The name of properties to match.

vValue Object

The value of properties to match.

Inherited From:
See:

removeAllListeners()

Inherited From:
Deprecated:
  • This method has been replaced by #removeChildListeners which recurses the node tree. Removes all listeners attached to the properties contained by this PresentationNode.

removeChildListeners()

Removes all listeners attached to the properties contained by this PresentationNode, and any nodes it contains.

Inherited From:

setComponentFrame(oComponentFrame)

Presentation models can use the module:br-presenter/PresentationModel#getComponentFrame to receive a reference to the frame containing the module:br-presenter/component/PresenterComponent that this model resides within.

Parameters:
Name Type Description
oComponentFrame module:br-component/Frame

The frame within which the presenter component resides.