Data Source Objects

Data source objects implement a standardized model for delivering data to a Web-based document. The DSO allows a developer to decide the following:

  • How the data will be transported (using the HTTP protocol, for example)
  • How the data can be manipulated (sorting and filtering, for example)
  • Whether the data can be updated and, if so, what mechanism will be used for updating
  • How the data is stored (straight text or SQL, for example)
  • An object model for accessing the data with scripts

Internet Explorer ships several DSOs; however, sophisticated programmers might want to develop their own. DSOs can be written in languages such as Java or C++. Once written, the DSO works directly with Internet Explorer through a common interface. The data from a DSO can be manipulated through script on the Web page, or it can be automatically bound to particular HTML elements through data binding extensions supported by Internet Explorer.

Fortunately, you don't have to write your own DSO to take advantage of the data binding capabilities of Internet Explorer. The DSOs included with Internet Explorer are the Remote Data Service (RDS), the JDBC Java applet, the Tabular Data Control (TDC), and the extensible markup language DSO (XML DSO, discussed in a later chapter). Each DSO has its own benefits and drawbacks.

The Remote Data Service lets users work directly from a Web page to access, manipulate, and update data on any OLE DB provider (a term we'll explain later), including ODBC-compliant databases. (ODBC stands for open database connectivity, and as its name suggests, is an interface that allows access to databases.) Easy access to data has important implications for people working in disparate locations who share a central database such as one on a corporate LAN or WAN.

The JDBC applet is JavaBeans compatible and is supported in modern versions of Netscape Navigator as well as Internet Explorer 4 and 5. Netscape Navigator does not support automatic data binding to HTML elements in the same way as Internet Explorer, but the data can still be made accessible to scripts.

The Tabular Data Control, which uses a simple text file as the data source, is the easiest to implement and use on the client. Its major drawback is that it does not directly support the updating of data on the server. We will be using the TDC for most of the examples in this chapter.

DSOs can be written to perform various database functions. The Tabular Data Control, for example, can display, sort, and filter data by using script and Dynamic HTML. This functionality is possible because the DSO allows the data to be separated from the HTML code. As we described earlier, the DSO/data binding model treats the Web page as a template, which is filled with the data as specified by the DSO. The best online general programmer's reference for Microsoft data access technologies can be found at microsoft.com/data.

How Data Gets from the DSO to the Page

For a DSO to work, it must be present on the Web page (usually as an ActiveX control or Java applet). Once the DSO is on a page, two other types of components—data consumers and binding agents—are used to bring the data itself onto the page.

The Web page elements that render the data supplied by the DSO are called data consumers. These elements can be standard HTML tags such as SPAN, DIV, or TABLE or external objects such as ActiveX controls or Java applets. The data consumer used depends on the type of data supplied, which can be either single-value or tabular. For example, the DIV element could be used to display a single value from the current record supplied by the data source. The TABLE element, in contrast, could display an entire set of records from the data source.

Internet Explorer supports several HTML attributes used expressly for data binding by elements that are data consumers:

  • The DATASRC attribute identifies the DSO object by the object's ID.
  • The DATAFLD attribute indicates the column (the data field) exposed by the DSO.
  • The DATAFORMATAS attribute specifies how the data should be formatted—for example, in HTML orplain text.
  • The DATAPAGESIZE attribute indicates how many records are displayed at one time (for tables only).

Binding agents are also built-in components of Internet Explorer. They work completely in the background to identify and maintain the data supplied by the DSO. When a page is loaded, a binding agent identifies all the DSOs and data consumers on the page. It then maintains the synchronization of data between the DSO and data consumers and directs the data traffic both ways, from the DSO to the data consumer and, if the data is changed on the page, from the data consumer to the DSO. Now that you have some background information, let's get to work and do some data binding.



Dynamic HTML in Action
Dynamic HTML in Action
ISBN: 0735605637
EAN: 2147483647
Year: 1999
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net