JSP Web Target object model

Classes in the Web Target object model handle the complexities of data transfer, HTML generation, and JavaScript generation for client scripts. The non-4GL part of the JSP object model provides a set of utility Java classes that implement this functionality and encapsulate most of the JSP page's implicit objects. These object classes can be used on non-4GL Web pages as well as 4GL JSP pages. The JSP deployment controller imports the JSP object model for each JSP page it deploys.

For more information about the server scripts added by the JSP deployment controller, see “Transformations for JSP targets”.

Use of constructors

For Web site targets, you do not need to use a constructor for objects of type PSCommandClass, PSConnectionClass, or PSCursorClass. You can simply designate an untyped JavaScript variable to reference an instance of the object that is returned by the CreateCommand, CreateConnection, or CreateCursor methods. For JSP targets, you must assign a variable of the correct class type before you can create an instance of the object or call methods on it.

For more information about JSP constructors for Web Target object model classes, see the Web and JSP Target Reference.

Object model changes for JSP targets

A few Web Target object methods have either not been implemented for JSP targets or have changed syntaxes for JSP targets. The psServer GetConnection and MapPath methods and the SetSQL method on the PSCommandClass object are not implemented for JSP targets. The psServer CreateConnection method has separate syntaxes for JSP targets that allow it to return objects of the PSConnectionClass type for these targets.

The GetValue method on the PSCursor object does not return a value of a set datatype and therefore cannot be used with JSP pages. This method has been replaced by a series of methods that return values of a specific datatype.

Table 8-10: Object model methods for JSPs only

Method

Return value datatype

GetColumn<DataType> (String strColName) where <DataType> can be Boolean, Byte, Double, Float, Int, Long, Short, or String

Corresponds to DataType used in method name

GetColumn<DataType> (int iColNo) where <DataType> can be Boolean, Byte, Double, Float, Int, Long, Short, or String

Corresponds to DataType used in method name

GetColumnLength (String strColName)

int

GetColumnLength (int iCol)

int

GetColumnName(int iCol)

String

GetColumnType(int iCol)

int

GetColumnTypeName (int iCol)

String

GetPrecision(int iCol)

int

GetResultSet()

ResultSet

GetResultSetMetaData()

ResultSetMetaData

GetScale(int iCol)

int

These methods are described in more detail in the Web and JSP Target Reference. If the syntax of a method is target dependent, the Web and JSP Target Reference indicates the proper syntax to use for each target type.

Server-side events

When you enable 4GL functionality on a JSP page, you can rely on an event-driven infrastructure to handle many of the details of coding server scripts. The JSP 4GL object model provides foundation classes for the event-driven infrastructure, such as the server control classes, the DataWindow class, server variables, and parameter classes.

In JSP Web targets, you must script a return value for the server-side events of a 4GL Web page that have a return value as part of their event signature. If there is no return statement, a servlet translation error occurs at runtime. The following server-side events on the 4GL psPage object have boolean return types: BeforeAction, BeforeGenerate, FirstTime, RequestStart, ServerError, and Validate.

You can use the SetTrace method to trace the server-side events on a generated page. The psPage object in the JSP Web Target object model also has a method to check if tracing is on before you call other trace methods multiple times. The IsTrace method returns a boolean and takes no arguments.

Variables

When you create variables on the Variables page of the Page Properties dialog box for 4GL JSP pages, you must associate a datatype with each variable. The following variable datatypes are supported in 4GL JSP pages: boolean, byte, char, double, float, int, long, short, and String.

For more information on setting 4GL page and session variables, see “Setting up page and session variables”.