View model support for work with Business Objects (BO) providing higher-level BO related operations and building blocks for complex UIs such as forms, collections, charts and others.
Data driven applications consist of handful of patterns and behaviours which keep repeating again and again. ABCS recognizes this and provides for each of these patterns an abstraction called "archetype". The goal of archetype is to:
- hide low level repetitive programming details
- provide building blocks which describe application semantic and its purpose
- separate UI (which changes in time) from application business logic (which is fairly set)
- support rapid application building
The claim which ABCS makes is that any data driven application can be described using the archetypes architecture. That is, core of any data driven application is primarily about querying data, displaying data, capturing data.
Archetypes that are part of a page are generated into its view model
where you may access them as e.g. pageViewModel.Archetypes.customerTableArchetype
.
Note that archetypes may not be present on a page indefinitely. 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:
var archetype = pageViewModel.Archetypes.customerTableArchetype; if (archetype) { // do something with the archetype }
Known implementations of Archetype
are:
- CollectionArchetype
- Solves use-cases related to work with collection of data and collection components (table or list).
- DetailArchetype
- Solves use-cases related to work with a single record and a form component.
- Version:
- 16.3.5
- Source:
- See:
-
- CollectionArchetype for archetype working with collection of records.
- DetailArchetype for archetype working with a single record.
- PageViewModel to see how to access archetype instances in a page.
Methods
getEntity() → {entity/js/api/Entity}
stable API
Returns entity instance this archetype is bound to.
Note that there are cases when this may be undefined
,
such as when the entity is not found in the data model.
- Version:
- 16.3.5
- Source:
Returns:
entity the archetype is bound to. In special
occassions when the archetype is broken this may return undefined
.
- Type
- entity/js/api/Entity
Example
// expecting you have an instance of a page view model assigned to 'self'
// as this will often be the case in business actions code.
var pageViewModel = self;
var archetypeIds = Object.keys(pageViewModel.Archetypes);
archetypeIds.forEach(function (archetypeId) {
// get instance of bound entity for an archetype
var entity = pageViewModel.Archetypes[archetypeId].getEntity();
// you should always check if the value is defined as in rare cases
// the archetype may not give you the reference to its entity
if (entity) {
// print its name
console.log('Page contains an archetype with BO: ' + entity.getName());
}
});
getId() → {String}
stable API
Returns archetype's ID.
The ID is unique inside an ABCS page, not across whole ABCS application.
- Version:
- 16.3.5
- Source:
Returns:
- Type
- String
getObservables() → {Object}
stable API
Returns an object that contains a set of fields and observables you can bind to in your components and use to communicate with other components on a page bound to the same instances.
The content of the object is described in specific archetype instances:
- Version:
- 16.3.5
- Source:
- See:
-
- CollectionArchetype to see an example and description of what collection archetype's method returns.
- DetailArchetype to see an example and description of what detail archetype's method returns.
Returns:
observables exposed by the archetype
- Type
- Object
getType() → {viewmodel/js/api/ArchetypeType}
stable API
Returns type of the archetype.
Type defines the archetype's behaviour, methods, fields and observables. Currently known types are:
- ArchetypeType.COLLECTION identifies a CollectionArchetype working with collections.
- ArchetypeType.ENTITY_DETAIL identifies a DetailArchetype working with single record.
- Version:
- 16.3.5
- Source: