XVCL example - DBTable
The purpose of this example is to illustrate how you can use XVCL to create
HTML documents with content retreived from an external data source. The program
generates HTML table containing data from CUSTOMER.DB table in DBDEMOS database.
Press F9 to generate HTML content...
Components/classes used in this example
- TJvxHTMLTable - incapsulates HTML <TABLE> element.
- TJvxHTMLTableHeader - incapslates HTML <THEAD> element.
- TJvxHTMLTableBody - incapslates HTML <TBODY> element.
- TJvxHTMLTableRow - incapslates HTML <TR> element.
- TJvxHTMLTableHeaderCell - incapslates HTML <TH> element.
- TJvxHTMLTableDataCell - incapslates HTML <TD> element.
- TJvxDBDataSource - allows using database table as a source of
rows for <TBODY> element.
- TJvxXMLGenerator - generates XML/XHTML content from TJvxHTMLTable
object.
Key properties/technologies illustrated in this example
- TJvxHTMLTableBody.DataSource - allows using external data
source as a virtual storage of <TR> elements in table body. It is used
together with the Template property.
- TJvxHTMLTableBody.Template - used to define a prototype
of <TR> element. Each cell of the prototype row is connected to a field
in the database table. When used together with the DataSource property it
creates an effect of <TBODY> having a number of <TR> elements
equal to the number of records in the database table.
Note that all XVCL classes that descend from TJvxCompositeElement have these
capabilities. They are not unique to TJvxHTMLTableBody class.
Implementation details
This example creates a template of an HTML document (FTable). The table consists
of header and table body. The header has one row populated with cells displaying
field names (see CreateTableHeaderRow method). Table body is connected to an
external data source (FNodeSource: TJvxDBDataSource). Table body has a template
row with cells connected to data fields provided by external data source (see
CreateTableBodyRow method). FNodeSource is connected to the database using
standard TTable (CustomerTable) and TDataSource (CustomerDataSource) components
pointed to CUSTOMER.DB table in DBDEMOS database.
An instance of TJvxXMLGenerator class is used to generate HTML content using the
template. Generated content is saved in Output.htm file.
Copyright © 2000-2001 XVCL