PageContext and PageManager JavaScript classes

Client-side JavaScript Calipso programming heavy relies in two classes:

This is the order the order on which above events get raised:
  1. Init. PageManager raises this event so listeners can initialize resources prior to rendering.
  2. Ready. PageManager raises this event in order to tell listeners than can start rendering things, for example, controls.
  3. ControlInit. PageManager raises this event in order to tell listeners that a control is being initialized.
  4. ControlReady. PageManager raises this event in order to tell listeners that a control is ready (it has been rendered an initialized).
  5. Loaded. PageManager raises this event in order to tell listeners that all resources handled by itself have been already loaded.

In order to add a listener, you need to get an instance of PageManager from the PageContext:
Comkarl,Web.PageContext.get_Manager()


Event handlers are added using PageManager AddEventNameListener(...) methods. Handling some events may require functions accepting specific arguments:

Init event

It requires a parameterless function:
Comkarl,Web.PageContext.get_Manager().AddInitListener(
    function() {
           // Do sfuff
    }
);

Ready event

It requires a function that recieves a single argument pageManager which is an instance of the PageManager that raised the event:
Comkarl,Web.PageContext.get_Manager().AddReadyListener(
    function(pageManager) {
           // Do sfuff
    }
);

ControlInit event

It requires a function that recieves a single argument control which is an instance of the control that's being initialized:
Comkarl,Web.PageContext.get_Manager().AddControlInitListener(
    function(control) {
           // Do sfuff
    }
);

ControlReady event

It requires a function that recieves a single argument control which is an instance of the control that acquired ready state:
Comkarl,Web.PageContext.get_Manager().AddControlReadyListener(
    function(control) {
           // Do sfuff
    }
);

Loaded event

It requires a function that recieves a single argument pageManager which is an instance of the PageManager that raised the event:
Comkarl,Web.PageContext.get_Manager().AddLoadedListener(
    function(pageManager) {
           // Do sfuff
    }
);