Dynamic Table CGIThe Dynamic Table CGI is a support CGI for HTML applications. The purpose of this CGI is to create a dynamic table from a NetPhantom list box, using different templates for each row. Below is an example of a list box where the header is displayed every time the first digit in the customer ID changes. Click here to run the sample application. Click here to view the Java source code.
The CGI is made to simplify this process, but it still requires some work. One column in the list box must contain the short name of the template for that row; this is usually handled from REXX. Template filesEach row in the list box uses one HTML template file. The template file should contain ordinary HTML code and could also include special variables, much like the NetPhantom HTML variables. This is an example of the <TR> <td bgcolor="00AAFF" align="left"><i>Customer</i> </td> <td bgcolor="00AAFF" align="left"><i>Name</i> </td> <td bgcolor="00AAFF" align="left"><i>Last purchase</i> </td> <td bgcolor="00AAFF" align="right"><i>Amount</i> </td> </TR> <TR> <td>@*_2;</td> <td>@*LINK_OK;> @*_3; </A></td> <td>@*_4;</td> <td align="right">@*_5;</td> </TR> Template variablesTemplate variable always start with "@*" and end with ";".
NetPhantom CGI
Insert the class using the Server Administration client menu item Server – Configure – Web
server. On the CGI tab Specify Name List boxThe list box must contain a column in which REXX code can insert the short name of the template for each row (see the Template column in the example below). The first column is searched by default.
Include HTML file referenceThe CGI is referenced from the HTML file for the current panel (in this case "CUSTSRCH"). Syntax of include statement:
<%@include cgi="DYNTABLE"
listid="CTLID"
[listboxcolumn=1..n]
[ShortName1=FileName1]
[ShortName2=FileName2]
...>
Parameters:
Example:
<%@include cgi ="DYNTABLE"
listid="LIST"
head ="HeaderTemplate.html"
row ="RowTemplate.txt">
Global variablesAn alternative to using parameters in the
/* Set listbox ID */
ret = GlobVarSet('HTMLDYNAMICTABLE_LISTID','LISTID')
/* EXAMPLE: Setup template file names */
ret = GlobVarSet('HEAD','HeaderTemplate.html')
ret = GlobVarSet('ROW','RowTemplate.html')
So what is the CGI good for?The CGI can be used in different ways. It provides a flexible way of handling complicated lists. If you think about your own applications, you may find that it is the answer to problems you didn't know you had. The sample shows how to use two different template files containing one or more HTML table rows. The actual <table> and </table> tags should be located in the main HTML file, not in the template. Another way in which you could use the CGI is to create one table in every template file. You can also have more than one include in an HTML file. This could be useful when you have a list that contains rows that are too long to be contained on a single line and therefore require two lines per row in the host. Usually two or three template files are used, but there is no limit. Try to create templates with names that are reusable throughout the application. The following check list describes the basic steps required when using the DynamicTableCGI.
|