Writing scripts to populate JavaScript Table
Once you created a JavaScript Table and specified its structure, you need to write a script that will populate the table with the required data.
About this task
You write the script in the JavaScript Table editor according to general JavaScript syntax rules. The editor opens automatically after you close the Create New JavaScript Table wizard.
To manage the content of a JavaScript Table, you can also use the following special functions of
the table global object:
- appendData()
- Inserts the data specified by a two-dimensional array to the end of the JavaScript Table.
- replaceData()
- Completely replaces the content of a JavaScript Table with the data
specified by a two-dimensional array of the following form:
[[<row 1 column1>, <row 1 column 2>,...], [<row 2 column 1>, <row 2 column 2>,...],...]
. - eraseData()
- Removes JavaScript Table records that satisfy the specified SQL condition. If you call eraseData() function without arguments or with null argument, all table records are removed.
- setTag()
- Links the JavaScript Table with some additional information specified by a string. This information can be retrieved by the getTag() method. To clear the information, use setTag() with null argument or without arguments.
- getTag()
- Returns the additional information related to the JavaScript Table.
- include()
- You can include external code in your JavaScript Table script by using the include() method.
- appendData()
- Inserts the data specified by a two-dimensional array to the end of the JavaScript Table.
- replaceData()
- Completely replaces the content of a JavaScript Table with the data specified by a
two-dimensional array of the following form:
[[<row 1 column1>, <row 1 column 2>,...], [<row 2 column 1>, <row 2 column 2>,...],...]
. - eraseData()
- Removes JavaScript Table records that satisfy the specified SQL condition. If you call eraseData() function without arguments or with null argument, all table records are removed.
- setTag()
- Links the JavaScript Table with some additional information specified by a string. This information can be retrieved by the getTag() method. To clear the information, use setTag() with null argument or without arguments.
- getTag()
- Returns the additional information related to the JavaScript Table.
- include()
- You can include external code in your JavaScript Table script by using the include() method.
To trace HTTP request, response, and record logs, use the log() function.
You can also use prompted variables in the script.
A user will be prompted to enter variable values when running a query
based on the created JavaScript Table. If you use a prompted variable
in the script, note the following peculiarities:
- The JavaScript Table cache is ignored.
- When a user works with a JavaScript Table in QMF for WebSphere®, all the retrieved data will be available to that user only.
You can work with the preset modules or create custom ones.
When you finish working with the script, save the changes and close the editor.