Приглашаем посетить
Data Binding with HTML
Chapter 15
Data Binding with HTML
Until the arrival of data binding, accessing data via Web pages was slow.
(And the Internet has become slower as traffic has increasedespecially if
you're limited to a 28.8-Kbps modem.) Pages that accessed data were slow to
render. This was due, in large part, to servers not only supplying Web pages but
also being tasked with accessing the database and merging the data with the
page to create a complete HTML page for the client. Moreover, once that page
was transmitted to the client there was no way for the client to differentiate
between the data and the HTML that contained it. As a result, when users wanted
to manipulate the datafor example, to sort it in a different orderthey
needed to make another request to the server. Such a request would result in the
server accessing the same data again, formatting it differently, and transmitting
the new page to the client. The server would once again transmit the same
data embedded in the HTML page to the client. Some servers were also
required to maintain client state to ensure that data was consistently displayed to
the user. All these factors resulted in a user experience equivalent to
mainframe terminals in terms of interactivity. Fortunately, all this has changed.
Enter data binding. Data binding is a feature of Dynamic HTML
that solves many of these problems. Data binding maintains the distinction
between the data and the HTML that displays it. Data is transmitted to the client
asynchronously and rendered asynchronously as it arrives, much like a
progressively rendered GIF. Because the client is able to differentiate the data, it can
perform manipulations, such as sorting, on the client without a round-trip to
the server. This autonomy reduces the number of server hits and the amount
of data transmitted. Web pages built using data binding display data more
quickly, remove the burden of formatting from the server, and provide a more
interactive, responsive experience to the user by eliminating long waiting
periods between pages.
The goal of this chapter is to give you enough information to build
an HTML page using data binding as well as to provide a reference as
you build data-bound pages. The following topics are covered in this chapter:
- What is data
binding? Data binding is a concept introduced in
Dynamic HTML. This section defines the term
binding and introduces the concepts that will be explored in the remainder of this chapter.
- Data-binding
architecture This section discusses the three
components of the data-binding architecture: data source objects,
HTML data-binding extensions, and the binding and repetition agent.
Data source objects supply data to Web pages and encapsulate the
functions of transmission, specification, manipulation, and script
access. The HTML data-binding extensions are attributes that can be
included on HTML elements. Elements that include data-binding
attributes are called data consumers. The attributes specify the
data source object that supplies data to the element. The binding
and repetition agent recognizes data source objects and data
consumers on a Web page and synchronizes data transfers between the
HTML elements and the data source.
- Data consumers: HTML
elements A large number of HTML elements support data binding. This section provides a list of
these elements and explains how they are used to display and allow
user interaction with the data supplied by a data source object. This
section also provides examples that demonstrate how to bind each
supported HTML element.
- Building basic pages using data
binding This section discusses the three basic types of binding: current record binding, repeated
table binding, and paged table binding. Current record binding
displays data from the current record in bound elements. You can use a
script to change which record in the data set is current. When a new
record becomes current, the bound elements are updated to show data
from that record. Repeated table binding allows the Web author to
repeat a set of HTML elements, called a template, to build a table that
displays all the rows in a data set. Paged table binding is similar to
repeated table binding except that it allows the Web author to
limit the number of records displayed in the table. The paged table
can be thought of as a window into the data set. Using scripts, the
Web author can then move this window around the data set to
display additional data.
- Writing scripts using data
binding As part of the data-binding functionality, a rich event model is provided to Web authors for
writing applications. Events are provided for validation, record
movement, and asynchronous data transmission. This section also
describes the basics of accessing data from a data source object using
ADO (ActiveX Data Objects).
- Advanced
features This section gives a brief overview of a
number of advanced features of data binding, including data updates, the recordNumber property, and object model access to the
data-binding attributes. This section discusses how a Web page can
be made into a client/server application by enabling data
updates. The recordNumber property, available from every element in a
repeated or paged table, allows the Web author to easily
determine to which record from the data source object the element is
bound. The remainder of the section discusses adding, deleting, and
modifying data-binding attributes on elements using the
Dynamic HTML object model.
[Содержание]