IBM Books

Net.Data Language Environment Reference

Java Applet Example

The following example demonstrates a Net.Data macro file that calls the Java applet language environment and the resulting applet tag that the language environment generates.

The Net.Data macro file contains the following function calls to the Java applet language environment:

%define{
DATABASE = "celdial"
DTW_APPLET_ALTTEXT = "<P>Sorry, your browser is not Java-enabled."
DTW_DEFAULT_REPORT = "no"
MyGraph.codebase = "/netdata-java/"
MyGraph.height = "200"
MyGraph.width = "400"
MyTitle = "This is my Title"
%}
%FUNCTION(DTW_SQL) mySQL(OUT table){
select name, ages from ibmuser.guests
%}
%HTML(report){
@mySQL(MyTable)
@DTWA_MyGraph(MyTitle, DTW_COLUMN(ages) MyTable)
%}

The Net.Data macro lines in the DEFINE section specify the first line of the applet tag:

MyGraph.codebase = "/netdata-java/"
MyGraph.height = "200"
MyGraph.width = "400"

The language environment generates an applet tag with the following qualifiers:

<applet code = 'MyGraph.class'
codebase = '/netdata-java/' width = '400'
height = '200' >

Net.Data returns the SQL query results from the SQL section of the Net.Data macro file in the output table, MyTable. This table is specified in the DEFINE section:

MyTable = %TABLE(all)

The call to the applet in the macro is specified in the HTML section:

@DTWA_MyGraph(MyTitle, DTW_COLUMN(ages) MyTable)

Based on the parameters in the function call, Net.Data generates the complete applet tag containing the information about the result table, such as the number of columns, the number of rows returned, and the result rows. Net.Data generates one parameter tag for each cell in the result table, as shown in the following example:

param name = 'DTW_MyTable_ages_VALUE_1' value = "35">

The parameter name, DTW_MyTable_ages_VALUE_1, specifies the table cell (row 1, column ages) in the table, MyTable, which has a value of 4. The keyword, DTW_COLUMN, in the function call to the applet, specifies that you are interested only in the column ages of the resulting table, MyTable, shown here:

@DTWA_MyGraph( MyTitle, DTW_COLUMN(ages) MyTable )

The following output shows the complete applet tag that Net.Data generates for the example:

<applet code = 'MyGraph.class'
codebase = '/netdata-java/' width = '400' height = '200' >
<param name = 'MyTitle' value = "This is my Title" >
<param name = 'DTW_NUMBER_OF_TABLES' value = "1" >
<param name = 'DTW_TABLE_1_NAME' value = "MyTable" >
<param name = 'DTW_MyTable_NUMBER_OF_ROWS' value = "5" >
<param name = 'DTW_MyTable_NUMBER_OF_COLUMNS' value = "1" >
<param name = 'DTW_MyTable_COLUMN_NAME_1' value = "ages" >
<param name = 'DTW_MyTable_ages_VALUE_1' value = "35">
<param name = 'DTW_MyTable_ages_VALUE_2' value = "32">
<param name = 'DTW_MyTable_ages_VALUE_3' value = "31" >
<param name = 'DTW_MyTable_ages_VALUE_4' value = "28" >
<param name = 'DTW_MyTable_ages_VALUE_5' value = "40" >
<P>Sorry, your browser is not Java-enabled.<BR>
</applet> 


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