Cisco Cisco Collaboration Server Dynamic Content Adapter
DCA 2.01 Administration and Configuration Guide
About Rule Scripts 125
About Rule Scripts
The most common place to employ scripts are within a Rule element. Rule scripts are
applied based on text matched by a rule's Accept statement. The standard behavior
of a rule script is to take the parsed match provided in match, change the value of a
subgroup, then set that value again. This operation is repeated many times during a
single document reformatting to produce an entirely new document.
applied based on text matched by a rule's Accept statement. The standard behavior
of a rule script is to take the parsed match provided in match, change the value of a
subgroup, then set that value again. This operation is repeated many times during a
single document reformatting to produce an entirely new document.
The scripts provided with the standard DCA installation are a good place to start
when looking for Rule script examples.
when looking for Rule script examples.
Rule Script Events
Each rule has two events for which scripts can be written. A rule can contain a
maximum of one script per event type.
maximum of one script per event type.
• ON_MATCH: Scripts written for the On_Match event are called when a rule is
initially matched during document parsing.
The On_Match event is usually the best place to call scripts that modify matched
text. Scripts called from On_Match can be used to alter parsing process from that
point forward.
text. Scripts called from On_Match can be used to alter parsing process from that
point forward.
• ON_RENDER: Scripts written for the On_Render event are called when a
document is being rendered to be sent to a client.
Generally, scripts called from the On_Render event should be limited to output
formatting (including modification of links to point to the DCA). On_Render is also
the appropriate place to call scripts that format a document differently for
different users (for example, one that formats a page differently depending on
whether the requester is a caller or agent).
formatting (including modification of links to point to the DCA). On_Render is also
the appropriate place to call scripts that format a document differently for
different users (for example, one that formats a page differently depending on
whether the requester is a caller or agent).
The Match and Data Objects
The script blocks associated with rules in the DCA parser are similar in nature to
JavaScript functions (and in the client, they are exactly that). Each function is called
with two arguments, Data and Match. Data and Match are Java objects put into the
script environment and are available to scripts at runtime. They are essential to any
rule script functionality.
JavaScript functions (and in the client, they are exactly that). Each function is called
with two arguments, Data and Match. Data and Match are Java objects put into the
script environment and are available to scripts at runtime. They are essential to any
rule script functionality.
• The Data object provides request information to the script, such as session ID