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:
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.<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>
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.
<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:
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.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.
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.