Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

About This Book [Table of Contents] Chapter 2: Using DataWindow Objects

DataWindow Programmer's Guide

[-] Chapter 1: About DataWindow Technology

Chapter 1

About DataWindow Technology

About this chapter

This chapter describes what DataWindow objects are and the ways you can use them in various application architectures and programming environments.

About DataWindow objects, controls, and components

DataWindow technology is implemented in two parts:

DataWindow controls and components

The DataWindow was originally invented for use in PowerBuilder to provide powerful data retrieval, manipulation, and update capabilities for client/server applications. Now the DataWindow is available in several environments:

For a comparison of each of these environments, see "Choosing a DataWindow technology".

You can also use DataStore objects as containers for a DataWindow object. DataStores provide DataWindow functionality for retrieving and manipulating data without the onscreen display. Uses for DataStores include specifying layouts for printing and managing data in the server component of a distributed application.

What DataWindow objects are

A DataWindow object is an object that you use to retrieve, present, and manipulate data from a relational database or other data source (such as an Excel worksheet or dBASE file). You can specify whether the DataWindow object supports updating of data.

DataWindow objects have knowledge about the data they are retrieving. You can specify display formats, presentation styles, and other data properties to make the data meaningful to users.

In the DataWindow painter, you can also make Powersoft report (PSR) files, which you can use in DataWindow controls or components. A PSR file contains a report definition--essentially a nonupdatable DataWindow object--as well as the data contained in the report when the PSR file was created. It does not retrieve data.

Where to define DataWindow objects

You define DataWindow objects in the PowerBuilder DataWindow painter. You can also define nonupdatable DataWindow objects in the InfoMaker Report painter.

Presentation styles and data sources

When you define a DataWindow object, you choose a presentation style and a data source.

Presentation styles

A presentation style defines a typical style of report and handles how rows are grouped on the page. You can customize the way the data is displayed in each presentation style. The presentation styles include:

Table 1-1: DataWindow presentation styles

Presentation style

Description

Tabular

Data columns across the page and headers above each column. Several rows are viewable at once.

Freeform

Data columns going down the page with labels next to each column. One row displayed at a time.

Grid

Row-and-column format like a spreadsheet with grid lines. Users can move borders and columns.

Label

Several labels per page with one row for each label. Used for mailing and other labels.

N-Up

Two or more rows of data next to each other across the page. Useful for periodic data, such as data for each day of the week or each month in the quarter.

Group

A tabular style with rows grouped under headings. Each group can have summary fields with computed statistics.

Composite

Several DataWindow objects grouped into a single presentation. Not supported by the Web DataWindow.

Graph

Graphical presentation of data. Not supported by the Web DataWindow.

Crosstab

Data summary in a row-and-column format.

RichText

Paragraphs of text with embedded data columns. Not supported by the Web DataWindow or the Sybase DataWindow Web control for ActiveX.

OLE

An OLE object linked or embedded in the DataWindow and associated with the retrieved data. Not supported by Web DataWindow.

For examples of the presentation styles, see the PowerBuilder User's Guide.

Data sources

The data source specifies where the data in the DataWindow comes from and what data items are displayed. Data can come from tables in a database, or you can import data from a file or specify the data in code. For databases, the data specification is saved in a SQL statement. In all cases, the DataWindow object saves the names of the data items to display, as well as their data types.

Table 1-2: Data sources you can use for a DataWindow

Data source

Description

Quick Select

The data is coming from one or more tables in a SQL database. The tables must be related through a foreign key. You need to choose only columns, selection criteria, and sorting.

SQL Select

You want more control over the select statement that is generated for the data source. You can specify grouping, computed columns, and so on.

Query

The data has already been selected and the SQL statement is saved in a query object that you have defined in the Query painter. When you define the DataWindow object, the query object is incorporated into the DataWindow and does not need to be present when you run the application.

Stored Procedure

The data is defined in a database stored procedure.

External

The data is not stored in a database, but is imported from a file (such as a tab-separated or dBASE file) or populated from code.

Basic process

Using a DataWindow involves two main steps:

  1. Use the DataWindow painter to create or edit a DataWindow object.

    In the painter, you define the data source, presentation style, and all other properties of the object, such as display formats, validation rules, sorting and filtering criteria, and graphs.

  2. In your development environment, put a DataWindow control or component in a window, form, or Web page and associate a DataWindow object with it.

    It is through this control that your application communicates with the DataWindow object you created in the DataWindow painter. You write code to manipulate the DataWindow control and the DataWindow object it contains. Typically, your code retrieves and updates data, changes the appearance of the data, handles errors, and shares data between DataWindow controls.

Choosing a DataWindow technology

Since DataWindow technology can be used in different environments, it may not be obvious what approach you should take to implementing your data-enabled application. This section describes the DataWindow technologies available for three basic application architectures and the requirements for each DataWindow solution. See Building Internet and Enterprise Applications for further discussion of application architectures.

The basic architectures are:

Solutions for client/server and distributed applications

The PowerBuilder DataWindow was initially developed for use in client/server applications.

You can implement the PowerBuilder DataWindow as a control that displays a DataWindow object or as a DataStore that supports data retrieval and update without displaying the data. A complete set of events and methods programmed in PowerScript provides control over all aspects of the DataWindow, including data retrieval, display, validation, and update.

You can also deploy the PowerBuilder DataWindow as a component for use in distributed applications.

For more information, see "PowerBuilder DataWindow control".

Solutions for Web applications

You can use these DataWindow technologies in Web applications:

Web DataWindow

The Web DataWindow is a thin-client DataWindow implementation for Web applications. It provides most of the data manipulation, presentation, and scripting capabilities of the PowerBuilder DataWindow without requiring any PowerBuilder DLLs on the client.

Functionality

The Web DataWindow supports a subset of the PowerBuilder DataWindow events and methods, including dynamic modification of the DataWindow object. The user can modify and update data. Graph, OLE, and RichText presentation styles and controls are not supported.

Client requirements

The technology works in any browser, but the appearance of the generated HTML is usually best in Internet Explorer. Generated HTML can be dynamically optimized for Netscape or Internet Explorer, or scaled back to handle older browsers.

Server requirements

A component server and a dynamic page server work together to generate a client control with data and include it in a Web page. Each time the user requests a new page of data, updates data, or inserts or deletes rows, the server gets a request to generate a new page. Depending on how state is managed, the component may retrieve data each time it is called, causing added load on the server.

Development tools

The Web Target interface in PowerBuilder provides the Web DataWindow DTC that you can use to develop Web DataWindows without hand coding. You can also write your own server-side scripts to create Web DataWindows using the component server's API. You can write the scripts for interpretation by a specific page server type (PowerDynamo, Active Server Pages, or JavaServer Pages). For Web site targets, you can use the Web Target object model to write server scripts that are type-neutral--the scripts can be deployed to either PowerDynamo or Active Server Pages.

When you use the Web DataWindow DTC on a 4GL Web page, server-side events are available and page variables can enhance the dynamic capabilities of your Web application. You cannot hand code a Web DataWindow on a 4GL Web page.

For information about the Web DataWindow, see Chapter 6, "Using the Web DataWindow." For information about the Web DataWindow DTC, see Working with Web and JSP Targets.

Sybase DataWindow Web control for ActiveX

The Sybase DataWindow Web control for ActiveX is an interactive DataWindow control for use with Internet Explorer that implements all features of the PowerBuilder DataWindow except rich text.

Functionality

The Web ActiveX is fully programmable and supports DataWindow events, methods, and dynamic modification of the DataWindow object. The user can modify and update data. The RichText presentation style is not supported.

Client requirements

The control uses ActiveX technology and works in Microsoft Internet Explorer only.

The user must download the CAB file for the component, which is less than two megabytes in size. Database connection via JDBC occurs from the client, which must be configured with the connection software. The software can be downloaded from the Web server.

DataWindow behavior that would compromise security of the client, such as the SaveAs functionality, is disabled.

Server requirements

The JDBC database connection can access databases on a remote server.

Development tools

You can use the Web Target tools for working with ActiveX components to develop your Web application.

For information, see Chapter 8, "Using the DataWindow Web Control for ActiveX."

DataWindow plug-in

The DataWindow plug-in is a browser plug-in that displays Powersoft reports (PSRs).

Functionality

A PSR is a frozen DataWindow; it cannot be modified and the data does not stay current. However, a PSR is a compact representation of the DataWindow definition and data and can be downloaded efficiently. It is an efficient means of viewing batch-produced reports.

The user cannot modify or update the data.

Client requirements

The plug-in executable must be installed in the browser plug-in directory. It cannot be downloaded and installed automatically. The plug-in works in Netscape browsers. Internet Explorer browsers prior to version 5.5 also support the plug-in.

DataWindow behavior that would compromise security of the client, such as SaveAs, is not disabled.

Development tools

You can use PowerBuilder or InfoMaker to create PSRs.

For more information about the plug-in architecture, see Application Techniques.

PowerBuilder DataWindow control

Features

The PowerBuilder DataWindow control is a container for DataWindow objects in a PowerBuilder application. You can use it in a window to present an interactive display of data. The user can view and change data and send changes to the database.

In addition to the DataWindow control, the DataStore object provides a nonvisual container for server applications and other situations where onscreen viewing is not necessary.

The DataWindow supports data retrieval with retrieval arguments and data update. You can use edit styles, display formats, and validation rules for consistent data entry and display. The DataWindow provides many methods for manipulating the DataWindow, including Modify for changing DataWindow object properties. You can share a result set between several DataWindow controls and you can synchronize data between a client and server.

Development environment

You can develop both parts of your DataWindow implementation in PowerBuilder. You use:

In the PowerBuilder Browser you can examine the properties, events, and methods of DataWindow controls and DataStore objects on the system tab page. If you have a library open that contains DataWindow objects, you can examine the internal properties of the DataWindow object on the Browser's DataWindow tab page.

DataWindow objects

The DataWindow control or DataStore object uses a DataWindow object, which determines what data is retrieved and how it is displayed. The control can also display Powersoft reports (PSRs), which do not need to retrieve data.

A DataWindow object for a PowerBuilder application can have any presentation style.

Database connections

The PowerBuilder DataWindow can use ODBC, JDBC, and native database drivers for database connectivity. Users can connect to a data source on any server to which they have access, including databases and middle-tier servers on the Internet.

To make a connection, you can use the internal Transaction object of the DataWindow, or you can make the connection with a separate PowerBuilder transaction object.

A PowerBuilder application provides a default Transaction object, SQLCA; you can define additional Transaction objects if you need to make additional connections. When you connect with a separate Transaction object, you can control when SQL COMMIT and ROLLBACK statements occur, and you can use the same connection for multiple controls.

For more information about using a Transaction object with a DataWindow, see Chapter 2, "Using DataWindow Objects".

For more information about PowerBuilder Transaction objects, see Application Techniques in the PowerBuilder documentation set.

Coding

You write scripts in the Window or User Object painter to connect to the database, retrieve data, process user input, and update data.

In PowerBuilder, you can take advantage of object inheritance by defining a user object inherited from a DataWindow control and adding your own custom functionality. You can reuse the customized DataWindow control throughout your applications.

You create DataStore objects, the nonvisual version of a DataWindow control, by creating them in a script and calling methods for the object. You can also define a user object that is inherited from a DataStore and customize it. For more information, see Chapter 4, "Using DataStore Objects ".

Libraries and applications

You store DataWindow objects in PowerBuilder libraries (PBLs) during development. When you build your application, you can include the DataWindow objects in the application executable or in PowerBuilder dynamic libraries (PBDs).

For more information about designing DataWindow objects and building a PowerBuilder application, see the PowerBuilder User's Guide and Application Techniques.


About This Book [Table of Contents] Chapter 2: Using DataWindow Objects