Allaire

The DCF Interface

Initializing a Recordset by Column
Recordsets can be embedded in an HTML page as APPLET PARAMs that are read when a DCF-enabled applet is constructed. A simple single recordset initialization might look like this:

<HTML>
<HEAD><TITLE>DCF Applet Test</TITLE></HEAD>
<BODY>
<!-- A bunch of HTML could go here. -->

<APPLET CODEBASE="/classes/" CODE="MyJavaClass.class" WIDTH=640 HEIGHT=480>
   <PARAM NAME="Columns" VALUE="LarryCol,CurlyCol,MoeCol">
   <PARAM NAME="LarryCol" VALUE="5,7,2,1">
   <PARAM NAME="CurlyCol" VALUE="1,0,9,1">
   <PARAM NAME="MoeCol" VALUE="3,3,4,0">
</APPLET>

<!-- A bunch more HTML could go here. -->
</BODY>
</HTML>

In the preceding example, an applet using the DCF would call the AppletParamRecordset constructor to find the parameter named "Columns" to identify which parameters hold column data.

The AppletParamRecordset would proceed to populate columns of a DCF Recordset with the values listed in the "LarryCol", "CurlyCol", and "MoeCol" parameters. Thus, there would be four records, and the first record would consist of LarryCol="5", CurlyCol="1", and MoeCol="3".

The first column declared determines how many rows are expected by the number of cells it contains. Subsequently declared columns will be padded with empty cells or truncated if they do not contain the same number of rows as the first column.


Initializing a Recordset by Cell
In addition to passing an entire column in an applet parameter, you can set values on a cell-to-cell basis. Columns are enumerated as previously done, but individual cells can be identified by column name and row number (indicated by ".Rn"). In this example the "Ringo" column is defined cell-by-cell:

<APPLET CODEBASE="/classes/" CODE="MyJavaClass.class" WIDTH=640 HEIGHT=480>
   <PARAM NAME="Columns" VALUE="Name,Instrument,IsBreathing">
   <PARAM NAME="Name" VALUE="John,Paul,George,Ringo">
   <PARAM NAME="Instrument" VALUE="Guitar,Bass,Guitar,Drums">
   <PARAM NAME="IsBreathing.R1" VALUE="No">
   <PARAM NAME="IsBreathing.R2" VALUE="Yes">
   <PARAM NAME="IsBreathing.R3" VALUE="Yes">
   <PARAM NAME="IsBreathing.R4" VALUE="Yes">
</APPLET>

Initializing Multiple Recordsets
Multiple recordsets can be initialized by employing nearly the same techniques used for single recordsets. The only differences are that all parameters of a recordset must be share a common recordset name prefix, and the two-parameter AppletParamRecordset constructor is used. For example, the following snippet initializes two two-column recordsets named "Pigs" and "Bears," respectively:
<APPLET CODEBASE="/classes/" CODE="MyJavaClass.class" WIDTH=640 HEIGHT=480>
   <PARAM NAME="Pigs.Columns" VALUE="PigNum,HouseType">
   <PARAM NAME="Pigs.PigNum" VALUE="1,2,3">
   <PARAM NAME="Pigs.HouseType" VALUE="Straw,Sticks,Brick">

   <PARAM NAME="Bears.Columns" VALUE="Title,BearNum">
   <PARAM NAME="Bears.Title" VALUE="Papa,Mama,Baby">
   <PARAM NAME="Bears.BearNum" VALUE="1,2,3">
</APPLET>

Requesting Recordsets at Runtime
Using the Query class an applet can request a URL and parse recordsets out of the data returned. The DCF expects the URL to return data like this:
A bunch of data could be here.

Recordset: Pigs
Columns: PigNum,HouseType

1,Straw
2,Sticks
3,Bricks


Recordset: Bears
Columns: Title,BearNum

Papa,1
Mama,2
Baby,3

A bunch more data could be here.
Two carriage returns terminates the recordset, so there can be no more than one new line between the Columns identifier and the first record of the recordset. Note that the URL can refer to an HTML page, a file on a server, a Cold Fusion template, or any other URL that will return the expected recordset format.

Recordsets returned to an applet during execution are passed by row. The first row determines how many columns will be recognized. Subsequent rows will be padded with empty cells or truncated to match the column count from the first row.


Database Component Framework Contents


Copyright © 1996 Allaire Corp. All rights reserved.