Coding for the Web ActiveX
You can write scripts in the Web page to manipulate the DataWindow
data and presentation. The methods and events are similar to those
available in a standard DataWindow, but the events have been renamed
to match JavaScript naming conventions.
The properties, methods, and events—as well as the
DataWindow object properties and expression functions—are
documented in the DataWindow Reference
.
You can see a list of the properties, methods, and events
for the controls on the Components page of the System Tree or in
another tool for examining ActiveX controls.
The Script editor lets you write scripts for all events of
the Web ActiveX.
To write a script for a particular event in a
Web target:
-
In Page view, select a Web ActiveX that
you have inserted in the Web page
or
In
the Script editor, select the name of the DataWindow Web ActiveX
in the leftmost drop-down list. -
In the Script editor, select an event from the
second drop-down list. The drop-down list shows the event name and
the parameters whose values are available in the script. -
In the third drop-down list, select JScript as
the scripting language. -
Write code for the event. To call methods or access
properties without typing, drag them from the Page tab of the System
Tree to the editor.
Datatypes for method arguments and return values
Primitive types
JScript supports three primitive datatypes:
- string
- number
- boolean
Method arguments and return values and event parameters are
one of these basic types, or an object type.
DataWindow methods that deal with specific data types, such
as GetItemDecimal, are not available for the Web ActiveX. Instead,
you use the method that handles the more general data type, such
as GetItemNumber.
Date data types
PowerBuilder has several date and time data types, but in
JScript these all map to the Date object.
Enumerated data types
PowerBuilder enumerated data types have named values, but
in JScript, each value is a number. The list of numbers (and their
meaning) is documented in the DataWindow Reference
for
each enumerated data type.
Setting event return codes
The event return codes documented for DataWindow events are
also valid for the Web ActiveX. However, JScript does not support
return values for events. Instead, to specify a return code, you
call the SetActionCode method as the last line in the event script.
For example, the return code of the onItemError event allows
you to determine what happens when user-entered data fails a validation
rule. By specifying a return code of 3, you cause the Web ActiveX
to reject the data but allow focus to change. This statement would
be the last line of the onItemError event script:
1 |
This.SetActionCode(3); |