Internet Technologies:waa

Using the Standard Package DLL Professional

The WAA server development kit contains a standard Web application for accessing arbitrary database files. It is located in the ..\SAMPLES\WAA\ALASKA1 directory where you find the full HTML and PRG source code as well as a ready-to-use package DLL. If you don't own Xbase++ yet, you can develop Web applications with database integration using the ALASKA1.DLL package.

The standard Web application for databases provides for an Edit and a Browse view, data collection from remote workstations is possible as well as searching data remotely in index files, and filter conditions can be defined on the remote station to view subsets of records in a database file. An example of how to use the standard Web application is given in the file ALASKA1.HTML where all available database operations are used.

You can program your own Web database applications with the standard package DLL by using the predefined name/value pairs for hidden INPUT TYPEs. The two views, for example, can be programmed this way:

01: <HTML> 
02: <HEAD> 
03: <TITLE>Using the Standard Package-DLL</TITLE> 
04: </HEAD> 
05: <B>Connect to Customer database </B><HR> 
06: 
07: <TABLE ALIGN=LEFT COLS=2 WIDTH=250><TR> 
08: <TD> 
09: <FORM ACTION="/cgi-bin/waa1gate.exe" METHOD=POST> 
10:    <INPUT TYPE=hidden NAME="WAA_PACKAGE" VALUE="alaska1"> 
11:    <INPUT TYPE=hidden NAME="WAA_FORM"    VALUE="dbedit"> 
12:    <INPUT TYPE=hidden NAME="WAA_USE"     VALUE="customer.dbf"> 
13:    <INPUT TYPE=hidden NAME="WAA_OPTIONS" VALUE="RW"> 
14:    <INPUT TYPE=submit VALUE="   Edit   "> 
15: </FORM></TD> 
16: <TD> 
17: <FORM ACTION="/cgi-bin/waa1gate.exe" METHOD=POST> 
18:    <INPUT TYPE=hidden NAME="WAA_PACKAGE" VALUE="alaska1"> 
19:    <INPUT TYPE=hidden NAME="WAA_FORM"    VALUE="dbbrowse"> 
20:    <INPUT TYPE=hidden NAME="WAA_USE"     VALUE="customer.dbf"> 
21:    <INPUT TYPE=hidden NAME="WAA_OPTIONS" VALUE="RO"> 
22:    <INPUT TYPE=submit VALUE="Browse"> 
23: </FORM></TD> 
24: </TR></TABLE> 
25: </BODY> 
26: </HTML> 

This HTML code is all you need for displaying databases on a remote client station and storing remotely edited data on the server. The output looks like this:

Connecting to a DBF file

When the Edit pushbutton is clicked, all fields of the current record in the CUSTOMER.DBF file are displayed in an Edit view, while the Browse pushbutton causes the Web application to return data in tabular form to the client station.

Remote Edit view of a database
Remote Browse view of a database

The example code demonstrates the pattern for using the standard package DLL: the NAME= attribute of the <INPUT> tag selects a service while the VALUE= attribute is used to specify data for a Web application. We have seen "WAA_PACKAGE" and "WAA_FORM" in the previous section already. They are used to address the package DLL (alaska1 in lines 10 and 18) and the contained function (dbedit in line 11 and dbbrowse in line 19). The database to use in the Web application is specified with NAME="WAA_USE" in lines 12 and 20, where the VALUE= attribute indicates the name of the file (customer.dbf). The value "RW" for "WAA_OPTIONS" in line 13 means Read/Write and is the opposite of "RO" (read-only) used in line 21.

As a conclusion, the standard package DLL (ALASKA1.DLL) allows for programming standard database applications by using predefined NAME= attributes and specifying VALUE= data in the <INPUT> tag of your HTML page. All TYPE= attributes are hidden except TYPE=submit (lines 14 and 22). The table below gives an overview, a detailed description follows:

Name/Value pairs for the standard package DLL
Name Value description
WAA_PACKAGE Name of the DLL
WAA_FORM Name of the function
WAA_USE Database and index file to open
WAA_DBE Database Engine for opening the files
WAA_OPTIONS Edit mode and list of field names
WAA_KEY Record number or index key to search for
WAA_FILTER Filter condition for database

NAME="WAA_PACKAGE"

To access the standard package DLL, VALUE="alaska1" must be used.

NAME="WAA_FORM"

Two values can be specified for "WAA_FORM". VALUE="dbedit" displays the Edit view and VALUE="dbbrowse" creates a Browse view.

NAME="WAA_USE"

The database and optional index files are specified with "WAA_USE". The file name of the database comes first and may be followed by a comma separated list of index file names. If the file names do not include the directory, the files are searched only in the directory of the package DLL. For example, these are legal file definitions:

<INPUT TYPE=hidden NAME="WAA_USE" VALUE="customer.dbf,customer.ntx"> 

<INPUT TYPE=hidden NAME="WAA_USE" VALUE="d:\data\customer.dbf"> 

NAME="WAA_DBE"

The DatabaseEngine for opening the database file on the server can be selected with "WAA_DBE". Three DatabaseEngines are available for database handling: DBFNTX, DBFCDX and FOXCDX.

Available DatabaseEngines
VALUE= Description
"DBFNTX" *) Memo fields in DBT format, index file in NTX format (Clipper 5.2 compatible)
"DBFCDX" Memo fields in DBT format, index file in CDX format (compatible with Clipper 5.2 plus CDX RDD)
"FOXCDX" Memo fields in FPT format, index file in CDX format (Visual FoxPro compatible)
  1. Default

If "WAA_DBE" is omitted, the default DatabaseEngine is used (DBFNTX). The following two lines demonstrate how to open a database file together with a CDX index file:

<INPUT TYPE=hidden NAME="WAA_DBE" VALUE="DBFCDX"> 

<INPUT TYPE=hidden NAME="WAA_USE" VALUE="customer.dbf,customer.cdx"> 

NAME="WAA_OPTIONS"

The value for "WAA_OPTIONS" defines whether or not data can be edited on a remote station and which fields are displayed. The first option is "RW" (editable) or "RO" (read-only). After this, a comma separated list of field names can be specified. If no fields are given, all fields are displayed in a view. The following example specifies two fields that can be edited:

<INPUT TYPE=hidden NAME="WAA_OPTIONS" VALUE="RW,Firstname,Lastname"> 

NAME="WAA_KEY"

The purpose of "WAA_KEY" is to navigate the record pointer or to search for data if an index file is open. Without an open index file, the VALUE= attribute indicates the record number and must be provided using digits. If a database is opened along with an index file, the VALUE= attribute indicates the character string to search for in the index. Since it is only possible to search for character strings, the index expression must yield a value of the data type Character, or Valtype()=="C".

Examples for positioning the record pointer using the record number or using an index are found in the ALASKA1.HTML file. The number of the desired record or the string to search for is entered in the Web browser (client side), and an appropriate response is created by the standard package DLL on the server side.

NAME="WAA_FILTER"

With this attribute, a filter condition can be specified on the client side in the VALUE= attribute. This causes the Web application to respond with a subset of records, which is a recommended way for keeping the response time short. A filter is particularly useful for Browse views, since no filter results in an HTML page that lists all records of a database file. This can result in quite a long response time, depending on how many fields are to be displayed and how many records are stored in the database on the server.

The filter condition must be a valid Xbase++ expression that can be compiled using the macro operator. An example is this line:

<INPUT TYPE=hidden NAME="WAA_FILTER"  VALUE="EMP_ID=='0001'"> 

The filter expression is defined as hidden and the standard package DLL would return only those records where the field EMP_ID contains the string '0001'. If a filter expression is to be entered on a remote station, we would provide for an entry field in the HTML page:

Enter filter: <INPUT TYPE=text NAME="WAA_FILTER" SIZE=80> 

This example lets a user enter a filter condition which is processed by the standard package DLL. If a filter condition entered on a remote station contains wrong syntax or field names, the standard package DLL responds with an error message.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.