2.6 Accessing Element Properties
You can refer to an element in a report by its element ID. For example, to set the “text” property of an element with ID 'Text1', preface the property name with the element ID:
Text1.text = "testing";
The ID in this case needs to conform to JavaScript naming requirements (see Comments and Names). If the ID contains special characters or white space characters that do not conform to JavaScript naming, you can reference the element as a property of the top-level “report” object.
report["Text1"].text = "testing";
This is equivalent to the previous form of reference.
The script environment is organized into three scope levels. A script attached to an element runs within element scope. When a symbol (variable, property) is encountered in the script, the server checks for the reference in the following sequence:
1. Search element scope.
2. Search report scope.
3. Search global scope.

In practice, this means that in an element script, you can reference the element's own properties without the qualifying element ID. This is recommended.
background = java.awt.Color.red; // recommended
Text1.background = java.awt.Color.red; // this also works
In contrast, report-level script (e.g., onLoad Handler) can only reference element properties by qualifying with the element ID:
Text1.background = java.awt.Color.blue;
An element script can use the fully-qualified syntax to reference properties of other elements as well. However, see the precautions noted in Script Debugging.
See Also
Bean Scripting Scopes, for information on scoping issues related to report beans.
Report Handlers, for information on adding script at the report level.
Element Script, for information on adding script to elements.
| << 2.5 Host Environment | © 1996-2013 InetSoft Technology Corporation (v11.5) | 3 Element Script >> |