Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Configuring JavaScript Programs

    Use the following statement to configure a JavaScript program for the SRC VTA:

    shared vta group name processor scripts javascript name {script script;return-type return-type;return-attribute return-attribute;}
    1. From configuration mode, access the statement that configures a JavaScript script and specify the name of the JavaScript program. For example, to configure a JavaScript script called js1:
      [edit]user@host# edit shared vta group vta1 processor scripts javascript js1
    2. Specify a function body in JavaScript.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set script script

      To refer to the event attributes being processed, include the attribute name delimited by angle brackets (<and>). The JavaScript program can verify whether the event has the referenced attribute. If a referenced attribute does not exist in the event, the attribute’s value is null. The JavaScript program must return a value.

    3. (Optional) Specify the Java type of the return attribute.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set return-type return-type

      Where the return-type is one of the following:

      • Integer
      • Long
      • Float
      • Double
      • String
      • Boolean
    4. (Optional) Specify the name of the return attribute.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set return-attribute return-attribute

      Specify an attribute that provides the return value of the script as a valid Java identifier that subsequent actions and event handlers can refer to. If this attribute is not set, the return value is not added to the event as an event attribute.

      JavaScript scripts must return an attribute value. The name of a return attribute cannot start with an underscore (_) because these event attributes are reserved for internal use.

    Modified: 2012-06-25