iTP Active Transaction Pages (iTP ATP) Programmer's Guide

ATP Web Page and Script Structure
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide522292-002
3-8
Using Pathway TS/MP Servers from JavaScript
Displaying the Results
To display the results of the previous transaction, the script
(/examples/sql/homebank/Webpages/address.atp) reads the data back
from the cache. (Another implementation option would be to echo the new data from the
request, but reading the data back from the cache is easier to code and confirms that the
update took place.) To read the data, the script creates another instance of the atp.SQL
object. This time the SQL statement type is SELECT.
To execute the SELECT statement, the script first invokes the execute method to
establish the cursor. Then it invokes the next method to read the row. (For a SELECT
statement, the execute method does not automatically read the row.) No transaction
object was required because reading is an operation that can be safely repeated.
The script checks the error code, using the sqlcode property of the atp.SQL object,
and prints a message if appropriate.
The </SERVER> tag shows where a block of server-side JavaScript ends. A script can
include multiple blocks of server-side JavaScript, each delimited by <server>
</server> tags. It can also contain fragments of server-side JavaScript in
backquotes. To display the form, the script uses data from the atp.SQL object created
for the SELECT statement. (The column_values property of the atp.SQL object
is an array of values representing the contents of a row.)
Using Pathway TS/MP Servers from JavaScript
The directories called pathway and pathway_tools within the ATP examples
directory contains many examples that illustrate Pathway script structure. The file
/examples/pathway/homebank/Webpages/address.atp is functionally
the same as the SQL example described above but uses a different set of objects to send
a request to a server class.
Print the file or display it on the screen and refer to it as you read the next few
paragraphs.
Also print or display the file
examples/pathway/homebank/Webpages/send_to_server.inc, which
the address.atp script uses as an include file.
For detailed information about objects and methods used for access to NonStop TS/MP,
see Section 4, ATP Objects, Properties, and Methods
.
Definitions and Includes
The script begins with definitions of functions that validate components of a customer
name and address. They are in client-side JavaScript because there is no reason for
input-validation functions to occur on the server.
The body of the script begins by including several files that define required functions.
The tag <SERVER> shows where the server-side JavaScript begins.
The script checks security each time the page is loaded because the execution of a script
is context free: ATP does not implement the concept of a session.