cf2:ConstructionComponent

Purpose

This component provides support for constructing the Client Framework 2 XDIME pages. The page creation process is divided into several phases, and each component can add a JavaScript code to the selected phase. Refer to Constructing XDIME pages for further information.

The JavaScript code for each phase must be inside a function that is registered with the correct phase using the creation(), linking() and starting() following methods. When the page has finished loading on the client, the phases are iterated over in the correct order. For each phase the functions are called in the order in which they were added. When all the functions for all the phases have been called, then all the resources associated with this component are released.

Exported Features

cf2:ConstructionComponent

Imported Features

n/a

Component scope

Each component is created by and lives within the scope of a construction component. By default, a component cannot be accessed from outside that scope, the exceptions are components that are registered in the global component scope.

The global scope is a special component scope whose components are accessible from all scopes associated with the outermost construction component and those created for nested page fragments.

JavaScript

This component is provided by the V$.C object. For each phase it maintains a list of functions to be invoked.

creation(function), linking(function), starting(function)

Adds the function to the creation, linking or starting phase respectively. It is an error if a function is added to more than one phase. Please note that it is an error if these methods are invoked after the object has been marked as complete.

Parameter Description Type
function The function to add. Function
complete()

Marks the object as complete which means that it cannot be modified anymore; an attempt to call the phase specific methods will result in an error being thrown.

construct()

Marks the object as complete if it has not already been done, then creates a context object, constructs the components by iterating over the phases and invoking the functions in each phase, and then returns the context object.

clear()

Clears the data stored in the object. Once this method has completed any attempt to call any methods on the selected object will result in an error being thrown explaining that the object is now invalid.

Context objects

The following methods provide client-side support for resolving a component identifier to a component. Only the components that are referenced by id need to be registered. Components explicitly created by scripts do not need registering. This means that registration is not done automatically by components, but by the code. The context object supplied to the phase functions supports the following methods.

get(id)

Returns the component with the specified identifier. It is an error if the component does not exist.

Parameter Description Type
id The identifier under which the component was registered. String
add(id, component)

Registers the component with the specified identifier. It is an error if the component has already been registered with the same identifier.

Parameter Description Type
id The identifier of the component to register. String
component The component to register. Object
clear()

Clears the data stored in the object. Once this method has completed any attempt to call any methods on the selected object will result in an error being thrown explaining that the object is now invalid.

Example

V$C.creation(function (c) {
  var modelB1 = new DOMSlideModel();
  c.add('modelB1', modelB1);
  modelB1._bindToDOM('smbB1');
  c.add('rendererB1', new DOMSlideRenderer());
});

V$C.starting(function (c) {
  c.get('slideB1').setLoop(true);
  var timer1 = new V$.cf2.TimerQueue();
  var id1 = timer1.every(function () {
    c.get('slideB1').next()
  },
  2000);
});

Related topics