The table
element is perhaps the most
complex element. It contains the majority of the information needed
by DbForms to render the DbForms JSP tags. A
table
element is needed for for each
table to be used with DbForms.
A starting set of table
elements as
well as a basic dbconnection
element
can be generated using the DevGui tool. This tool, which is described in
Chapter 5, DevGui
,
verifies database connectivity and then uses JDBC
capabilities to query the metadata for tables in the database. This
can be a signficant time-saving step.
The nesting and ordering of subelements within each
table
tag is shown below.
<table> <field/> <calc/> <foreign-key/> <events> <event/> </events> <interceptor> <param/> </interceptor> <granted-privileges/> </table>
The top level subelements, field
through
granted-privileges
may each occur
zero or more times except events
which is optional but may appear a maximum of one time.
There is no element content in the any of the elements. All information is supplied in the attributes of these elements and the attributes of their subelements.
The table
element itself has one
required attribute,
name
, giving the name of the table
and a number of optional attributes. All of the attributes are listed below.
name
orderBy
dataAccessClass
org.dbforms.event.datalist.dao.DataSource
.
Optional.
escaperClass
org.dforms.util.IEscaper
.
Optional.
alias
blobHandling
classic
", DbForms will use its
original method of handling BLOBs which involved storing BLOB
data in individual disk files. When this attribute is omitted
or has any other value, the database management system is used
to store BLOBs in appropriate table columns. When classic BLOB
handling is used, the directory
and encoding
attributes of
field
subelements may be used
to control where and how BLOB files are handled. Optional.
defaultVisibleFieldsFormat
foreign-key
attribute
format
as a convenience
when fields from the table are referenced as foreign keys. See
Chapter 19, Foreign Key support within DbForms
for more information. Optional.
defaultVisibleFields
foreign-key
attribute
visibleFields
as a convenience
when fields from the table are referenced as foreign keys. See
Chapter 19, Foreign Key support within DbForms
for more information. Optional.
The field
element describes a column
in the table. There are two required attributes,
name
, giving the name of the column
in the table, and fieldType
, giving
the data type of the column. There are also many optional attributes.
All of the attributes are listed below.
name
fieldType
String.startsWith()
so,
for example, Oracle's varchar2
matches the varchar
type listed below.
Use of an unsupported column type will result in a Java exception
while reading the
dbforms-config.xml
file which will generally render the application unusable.
char
,
varchar
,
longchar
,
long varchar
, and
text
.
int
,
smallint
,
long
, and
tinyint
.
numeric
,
number
, and
decimal
.
date
,
timestamp
, and
time
.
double
,
float
, and
real
.
image
,
blob
, and
diskblob
.
bool
.
size
isKey
sortable
autoInc
directory
expression
alias
attribute in the
enclosing table
element.
Optional.
defaultValue
alias
escaperClass
org.dforms.util.IEscaper
.
Optional.
encoding
directory
attribute. When
encoding
is set to true, file
names for BLOB objects are generated by DbForms so there is no
possibility of one BLOB object overwriting another. If
encoding
is false or is omitted,
the remote file name of an uploaded BLOB file is used by
DbForms. This means that files of the same name will overwrite
each other. Optional.
The calc
element is similar to the
field
element except that the
encoding
attribute is not allowed. A
field defined within a calc
element
is not populated by the user. Rather, the value is generated by
an interceptor.
Columns in a table that are foreign keys in the SQL sense should be
described in using the element foreign-key
rather than the field
element. This allows DbForms to handle the field differently. There
are limitations, however, on DbForms foreign key handling. See
Chapter 19, Foreign Key support within DbForms
for more details.
Every table uses, by default, the standard event configuration
established in the events
subelement
nested directly within the root
dbforms-config
element. A developer
can choose, however, to override the event class associated with a
certain type of event, by adding and configuring the
events
element within a
table
element.
The events
element itself is merely a
container for one or more event
subelements within it. Element events
has no attributes.
Each event
element may have a number
of attributes and may enclose nested
param
subelements. See
Chapter 22, Pluggable events
and especially
Section 22.5, “Override the event classes on a table-by-table basis ”
for more details.
The interceptor
element is used for
declaring interceptor classes locally for a particular table. See the
discussion later in this chapter on the
interceptor
element for details of
the attributes and the param
subelement.
As mentioned in
Chapter 15, Application hook-ups (Interceptors)
,
it is also possible to
declare interceptors globally to apply to all tables. Globally
declared iterceptors are invoked for all tables but interceptors
declared for specific tables are invoked only for that table. If both
table-specific and global interceptors are defined, the table-specific
iterceptor is invoked first and, if it signals success, the global
interceptor is then invoked.
By default, all users of the DbForms application have full access to
read and write all of the tables defined in
dbforms-config.xml
.The
granted-privileges
element has four
optional attributes that can establish limits for specific user roles.
The attributes are select
,
insert
,
update
, and
delete
. User roles are those defined
in the application web.xml
file. See
Chapter 9, Security
for more details.