IBM Books

Net.Data Administration and Programming Guide for OS/400

HTML Blocks

The Net.Data macro file contains HTML blocks and the constructs in the HTML blocks that generate text presentation statements, such as HTML, to a Web browser. In a macro file, you must specify at least one HTML block , but can specify as many as you want. Each HTML block generates a single Web page at the browser. Net.Data processes only one HTML block each time it is invoked, and the contents of the HTML block control the rest of the Net.Data invocation. To create an application consisting of many Web pages, you can invoke Net.Data multiple times to process HTML blocks using standard HTML navigation techniques, such as links and forms.

Any valid text presentation statements, such as HTML or JavaScript, can appear in an HTML block. In addition, you can use INCLUDE statements, function calls, and variable references in an HTML block. The following example shows a common use of HTML blocks in a Net.Data macro:

%DEFINE DATABASE="MNS96"
 
%HTML(INPUT){
<H1>Hardware Query Form</H1>
<HR>
<FORM METHOD="POST" ACTION="/cgi-bin/db2www/equiplst.d2w/report">
<dl>
<dt>What hardware do you want to list?
<dd><input type="radio" name="hdware" value="MON" checked>Monitors
<dd><input type="radio" name="hdware" value="PNT">Pointing devices
<dd><input type="radio" name="hdware" value="PRT">Printers
<dd><input type="radio" name="hdware" value="SCN">Scanners
</dl>
<HR>
<input type="submit" value="Submit">
</FORM>
%}
 
%FUNCTION(DTW_SQL) myQuery() {
SELECT MODNO, COST, DESCRIP FROM EQPTABLE WHERE TYPE=$(hdware)
%REPORT{
<B>Here is the list you requested:</B><BR>
%ROW{
<HR>
$(N1): $(V1)    $(N2): $(V2)
<P>
$(V3)
%}
%}
%}
 
%HTML(REPORT){
@myQuery()
%}

You can invoke the Net.Data macro from an HTML link like the one in the following example:

<a href="http://www.ibm.com/cgi-bin/db2www/equiplst.d2w/input">
  List of hardware</a>

When the application user clicks on this link, the Web browser invokes Net.Data, and Net.Data parses the macro file. When Net.Data begins processing the HTML block specified on the invocation, in this case the HTML(INPUT) block, it begins to process the text inside the block. Anything that Net.Data does not recognize as a Net.Data macro language construct, it assumes to be an HTML statement and sends to the browser for display.

After the user makes a selection and presses the Submit button, Net.Data runs the ACTION part of the HTML FORM element, which specifies a call to the Net.Data macro's HTML(REPORT) block. Net.Data then processes the HTML(REPORT) block just as the HTML(INPUT) block was.

Net.Data then processes the myQuery() function call, which in turn invokes the SQL FUNCTION block. After replacing the $(hdware) variable reference in the SQL statement with the value returned in the input form, Net.Data runs the query. At this point, Net.Data again starts sending the HTML report to the browser, displaying the results of the query according to the text presentation statements specified in the REPORT block.

After Net.Data completes the REPORT block processing, it returns to the HTML(REPORT) block, and finishes processing.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]