Velocity API: WLEvent.registerScope()

Version 2

    Return To Index

    WLEvent.registerScope()

    Overview

    Register a function to be run when a specific scope is entered.

    Added in version 1.2.0

    See Also
    • WLEvent.enterScope()
    • WLEvent.unregisterScope()

    Format

     

    var reference = WLEvent.registerScope(scope, funcRef, objectInstance, paramArray);
    ParameterDescriptionTypeRequiredNotes
    scopeThe name of the scope for which the specified function will be invoked.StringRequiredSee Velocity Scopes.
    funcRefThe function to invoke when the specified scope is entered.FunctionRequired
    objectInstanceThe value of this provided for the call to funcRef.ObjectRequiredThis parameter may be null.
    paramArrayAn array of parameters to pass to the specified function when it is invoked.ArrayRequired
    referenceAn object returned from the registration that can be used to unregister at a future point.ObjectReturnedShould be saved if the registration will be removed in the future.

     

    Example

    /* The onError function is registered to the "session" scope. 
    */
      
    function doOnSession(param1, param2) {
        Logger.debug("doOnSession(" + param1 + "," + param2 + ")");
    }  
    WLEvent.registerScope("session", doOnSession, null, ["value1", 2]);

    Velocity Scopes

     

    ScopeDescriptionVersion Added
    "global"A scope that is never entered, but always present at the bottom of the scope stack.1.2.0
    "session"A scope entered when the session is starting, lasting through the whole session.1.2.0
    "@<template>"A scope entered when a template is matched. A blank <template> indicates that no template was matched and a predictive template was created.1.2.104
    "@<template>:<fieldId>"A scope entered when a field contains the cursor. A blank <fieldId> indicates that the cursor is not currently in a field.1.2.104