Form definition files (.fdf's) are basically just a set of attribute definitions. First a set of attributes for the form as a whole are defined, then a set of attributes for each field in the form. All attribute definitions are of the form:
Attribute [= value]
where the name of the attribute is required, but the specified value may be optional. See the definitions below to determine if an attribute requires a value.
Blank lines and all characters after a '#' are ignored. It is important that there are no whitespace before the attribute name. Lines beginning with white-space are considered continuation lines of the previous attribute definition. Leading and trailing whitespace are removed from the attribute values.
INCLUDE field type
If you find yourself adding the same FDF form and field attributes over and
over in several FDFs, now you can put them all in a single file and just
include them in your other FDFs. Just specify a line of the form:
INCLUDE = /filesystem/path/to/your/include/fileand anything you put in the included file will show up in WDBI as if they were explicitly written in the FDF.
All form attributes are always before any field definitions in the file, and always in CAPITAL letters.
In the following an (R) means that the attribute is required, and an (E) means that the attribute values is evaluated by a perl eval command. Remember to quote strings in attribute values that are evaluated!
Ordinarily, WDBI performs a check to be sure the data in the database has not changed since a user selected the data for delete. If the data has changed, the update is aborted to keep from overwriting another user's changes. If you prefer that WDBI not make this check, specify:
ALLOW_DELETE = nocheck
Ordinarily, WDBI performs a check to be sure the data in the database has not changed since a user selected the data for update. If the data has changed, the update is aborted to keep from overwriting another user's changes. If you prefer that WDBI not make this check, specify:
ALLOW_UPDATE = nocheck
BODY_FORMAT = "BGCOLOR=\"#AABBCC\" TEXT=\"#FFFF00\""
CELL_FORMAT = ALIGN="LEFT" BGCOLOR="FFFFFF"
Note: you can override the global CELL_FORMAT attribute for selected table cells by using the cell_format field attribute for the selected cell(s).
<H1>
tag in the delete form.
Note: D_HEADER used to be the default header. To make
nomenclature more regular, the default header is now DEF_HEADER.
<H1>
tag in the result of a
default query page.
Note: in the original WDBI, this was D_HEADER. The name was changed because anything starting with D_ is now used to identify attributes associated with the delete action.
Note: in the original WDBI, this was D_HTML. The name was changed because anything starting with D_ is now used to identify attributes associated with the delete action.
<H1>
tag in the delete results page.
HEADER_FORMAT = ALIGN=LEFT COLSPAN=2
Note: you can override the global HEADER_FORMAT attribute for selected table headers by using the header_format field attribute for the selected header(s).
<H1>
tag in the insert form.
<H1>
tag in the insert results page.
Note: this is important so pay attention! If you use the JOIN attribute, the column attribute for every field used in the FDF must be fully qualified with the name of the table.
For example, if you join across the tables people and employment, and you have the fields name and address in the people table, and the fields salary and department in the employment table, you must change the column attributes for each field in the FDF to be like so: people.name, people.address, employment.salary, and employment.department. If you do not do this, WDBI does not know which fields belong to which table, and queries will not work. You have been warned.
<H1>
tag in the query form.
<H1>
tag in the result page.
<H2>
tag to add as a header to a record in full-screen
output mode. Typically the title of the row. For example in a FDF
that queries persons you might want a RECTOP like this :
RECTOP = "$val{'last_name'}, $val{'first_name'}";
number|datestring
. No numerical or date conversions are
performed by WDBI so you can use text numbers (i.e. three hundred) and any
date format you like just so they are separated with a '|' symbol.
<TITLE>
tag in all WDBI pages. If a
special header exists, such as D_HEADER or Q_HEADER,
they are no longer used instead of the TITLE attribute.
<H1>
tag in the update form.
<H1>
tag in the update results page.
Field attributes always appears after all form attributes in the file. The 'FIELD' attribute should always be the first attribute for a field. All attributes defined after this will belong to that field, until the next 'FIELD' attribute is met.
In the following an (R) means that the attribute is required, and an (E) means that the attribute value is evaluated by a perl eval command. Remember to quote strings in attribute values that are evaluated !
cell_format = ALIGN="LEFT" BGCOLOR="FFFFFF"yadda, yadda, blah, blah.
Note: If you want to define a cell format for an entire FDF, you can use the CELL_FORMAT form attribute. If you want some fields to have special formatting, you can use the cell_format to override the global CELL_FORMAT attribute.
compute_date = editand the date will be displayed in a textbox.
compute_datetime = editand the datetime will be displayed in a textbox.
enum = %=ALL,SOFT=Software,DATA=Data,DOC=Documentation
enum enum_perl = &my_enum_sub
from_db = sprintf("%8.2f", $val{'salary'} );
header_format = ALIGN=LEFT COLSPAN=2
Note: If you want to define a header format for an entire FDF, you can use the HEADER_FORMAT form attribute. If you want some headers to have special formatting, you can use header_format to override the global HEADER_FORMAT attribute.
This enables you to perform conditional joins that only search for data in a second table if the user requests it. The data from the primary is returned even if there is no data in the second table related to the first. This is sort of like an inner join, but if your database doesn't support inner joins, you can do the same thing with WDBI.
You might also check into the sub_query attribute.
image_src = "SRC=http://somewhere/cgi-bin/get_image.cgi/$val{'key'}"to pull an image out of the database based on the value of a field in the current record. Please replace key with the name of your key field.
Note: You can include more than just the SRC tag in the image_src attribute, such as HEIGHT=100 WIDTH=100.
makelist = employees%employee_id,name,departmentthen use:
list_display = $myrow{name} ($myrow{department})the displayed items will show the employee name and department in the list. You can access any field you specify in the makelist attribute from within the list_display attribute. Note: The default behavior for display is to use the first field as the value of the list item and the second is displayed to the user. If no second field is specified, the first field is used in the display.
multiple = 4or whatever you want the size to be.
list_off = query,updateLegal values are query, insert, or update. (Lists are not generated for delete forms.)
list_oneline = 3or whatever number you want to use.
makelist = employees%employee_id,name,departmentthen use:
list_value = $myrow{name}the employee name will be used as the value of the list item. You can access any field you specify in the makelist attribute from within the list_value attribute. Note: The default behavior for display is to use the first field as the value of the list item and the second is displayed to the user. If no second field is specified, the first field is used in the display.
lookup=tablename%fieldname%target_fieldname%target_value%extrawhere tablename is the name of the table to search, fieldname is the name of the field to select, target_fieldnameis the field to match against, target_value is the value to match, and extra is any extra query constraints added on to the select. The first four fields are required and the fifth is optional. From the above syntax, the following query would be constructed:
select fieldname from tablename where target_fieldname=target_value and extraNote: The target_value must be a numerical value. There is no way for WDBI to determine the datatype, so as most keys are numerical a number is assumed.
makelist = tablename%fieldname[%search parameters]where tablename is the name of the table to search, fieldname is the name of the field to select, and search parameters is the optional 'where' list to constrain the search. For example,
makelist = employees%namewould return the name of all employees. If you want to search for employees by group id and only return those who match a given group you can do something like this:
makelist = employees%group_id,name%group_id=4which would return a list of the names of all employees in group number 4. Any constraints added after the final '%' are made into a 'where' clause, i.e. the above example would add 'where group_id=4' to the query.
Note: in the original WDBI, this attribute was called simply html. The name was changed to more accurately reflect what it does and to show how it complements the new post_html attribute.
Note: the primary_key and key attributes are not the same. The key attribute is ignored on insert, update, and delete actions. The primary_key attribute is ignored during queries. This preserves the original function of 'key' while introducing new functionality for a primary key attribute.
Range...: 10 - 20 Hz
Some databases, such as mSQL 2, use sequences that provide you with a value before an insert. You must select a new sequence value, then use that value on an insert. Other databases, such as Informix, require you to insert a 0 in the serial field, and the database will insert a new value. The new value is returned by the database.
If you designate a field in the FDF to be both primary_key and serial_field, WDBI will use the newly generated key value as the value of any foreign_key fields when inserting into multiple tables across join conditions. In this manner, WDBI supports the use of unique key values generated by a database, even across join conditions on an insert.
This differing methodology requires WDBI to support two completely different methods of serial value generation. You will need to find out which method your database uses and tell WDBI which method to use.
For a database that generates a serial value prior to insert, such as mSQL
2, specify the serial_field attribute like so:
serial_field = pre_insert
For a database that generates a serial value on insert and returns the
value, specify the serial_field attribute like so:
serial_field = post_insertNote: be sure you have specified the field as serial type in the database, or no unique value will be generated. Another note: If you use SQL Server, this attribute is only supported under the InterLink ODBC driver. I've also tested the Microsoft and Intersolv drivers, and neither will support this feature.
sub_query = employee|"group_id = \"$val{'group_id'}\""This will use the employee.fdf file to display all employees with the current group_id. This lets you display multiple external records that are related to the current record. Use the SUB_QUERY_HEADER form attribute to specify an overall header to the sub_query results.
textarea = COLS=90 ROWS=8
Note: The TEXTAREA tag is assigned a NAME by WDBI that is the name of the database field it is related to. DO NOT specify a NAME in the textarea attribute, or undesirable behavior may occur.
|
char
|
datetime ]. This is currently only used in the
construction of the query to decide whether or not to put quotes around the
values, and whether or not the LIKE operator can be used.
url=$WDBI/$form{'NAME'}/query/$val{'keyfield1'}::$val{'keyfield2'}
Please note the use of the $WDBI variable instead of the name of the script (http://.../cgi-bin/wdbi/). This makes it easier to use more than one version of the wdbi script ( for example a development version and an installed version ).
There are some internal Perl variables that can be referenced in the attribute definitions above. Most of them have already been mentioned, but to summarize they are all listed here :
<
, >
, =
) has been removed. This is typically
used in to_db.
Note: May be overridden in the FDF with the MAXROWCOUNT attribute.
Note: May be overridden in the FDF with the ROWCOUNT attribute.
These are functions build into WDBI - However you can always add your own functions as well and include them either directly in the FDF file (under the PERL form attribute) or include them in your own Perl package and install it in your Perl library directory - then include them with the Perl 'require' statement in the PERL attribute or in the wdbi.conf file to make them available in all your FDF files.
url = "$WDBI/$form{'DATABASE'}/$form{'NAME'}/query/$val{'keyfield'}"
In this case you would have to encode the key value using cgi_encode like this :
url = "$WDBI/$form{'DATABASE'}/$form{'NAME'}/query/" . &cgi_encode($val{'keyfield'})
Copyright © 1996-98 Bo Frese Rasmussen and Jeff Rowe