|
contents intro dyno cgi |
Dyno CGI: TablesTableSubstitutionActionThis FieldSubstitutionAction subclass is an abstract base class that needs to be subclassed to provide implementation of a couple of key methods for starting, iterating over, and ending the table. TOCFilesTableSubstitutionAction is one such subclass. You can do some cool stuff by creating your own subclass. Basically, you'll need to override three methods:
TOCFilesTableSubstitutionActionThis FieldSubstitutionAction subclass implements a simple text-file-based database reading capability to output dynamic data records into an HTML table whose layout is in an HTML file. It starts with a "table of contents" text file. This file must contain one line per database record. The format of the line is simple a record identifier string. This string identifies the name of the file that contains the record's data. If you look at the code for TOCFilesTableSubstitutionAction, you can see that it wants the TOC file to be named table_of_contents.txt, and for the data files to be named <id>_data.txt where <id> is the record identifier string in the TOC file. You can change these if you like, or make a subclass of TOCFilesTableSubstitutionAction that overrides the accessors of these strings. The data files are formatted like Java properties files: each line is of the format "property=value" (without the quotes), and in our case the property name is the Dyno CGI substitution variable name, and the value is the string that it will be replaced with for this record. To format the table, you simply need to create a table in the HTML file. You can create a "header" row that contains column names if you wish. Then, you need to create one row that is preceded by a marker You may want to subclass TOCFilesTableSubstitutionAction if you need to convert any fields of the database records. For example, you might want to change a numeric string to a graphic indicator. Check out Example 05 for a lot of detailed comments about how this works. |