JavaScript Expressions

Use a JavaScript expression when the retrieval argument value requires processing before the DataWindow retrieves data. You can include variables that have been defined in another script on the same page in your JavaScript expression. Binding a retrieval argument to a JavaScript expression is not possible in a JSP target. To use a variable, you must declare the variable in a server script that runs before the Web DataWindow DTC.

NoteVerify in the Source view You can look at the page in Source view to make sure scripts appear on the page in the right order.

Example 1

Example 1

Using a JavaScript variable In this example, a server script establishes the value of the State retrieval argument. In the script, which must be executed before the DataWindow scripts on the page, the variable currstate is assigned a value. The script can do any other processing that you need.

var currstate = "MA";

On the Retrieval page of the Sybase Web DataWindow DTC Properties dialog box, specify currstate as a JavaScript expression for the state retrieval argument.

The sample shows the Retrieval page of the Sybase Web DataWindow DTC Properties dialog box. At top is a selected check box for Automatic Retrieval, then a display labeled Retrieval Arguments with columns for Argument Name, Bind Type, and Bind Value and one sample entry that reads state, Java Script Expression, and cur state.

Example 2

Example 2

Using an expression In this example, a server script on a login confirmation page for employees created a Userid property for the psSession object. The value was passed to the confirmation page as a page parameter.

psSession.SetValue("Userid",
		psDocument.GetParam("loginid"));

On some other page in the Web application, a Web DataWindow DTC can use the Userid value by specifying this expression on the Retrieval tab.

psSession.GetValue("Userid")
The sample shows the Retrieval page of the Sybase Web DataWindow DTC Properties dialog box. At top is a selected check box for Automatic Retrieval, then a display labeled Retrieval Arguments with columns for Argument Name, Bind Type, and Bind Value and one sample entry that reads state, Java Script Expression, and p s Session dot Get Value ( " User I D " ).