Example: Using ListRowData

This example has three parts:

Java source that shows how the ListRowData class works

         // Access an existing non-empty data queue
         KeyedDataQueue dq = new KeyedDataQueue(systemObject_, "/QSYS.LIB/MYLIB.LIB/MYDQ.DTAQ");
         
         // Create a metadata object.
         ListMetaData metaData = new ListMetaData(2);
         
         // Set first column to be the customer ID.
         metaData.setColumnName(0, "Customer ID");
         metaData.setColumnLabel(0, "Customer ID");
         metaData.setColumnType(0, RowMetaDataType.STRING_DATA_TYPE);
         
         // Set second column to be the order to be processed.
         metaData.setColumnName(1, "Order Number");
         metaData.setColumnLabel(1, "Order Number");
         metaData.setColumnType(1, RowMetaDataType.STRING_DATA_TYPE);
         
         // Create a ListRowData object.
         ListRowData rowData = new ListRowData();
         rowData.setMetaData(metaData);
         
         // Get the entries off the data queue.
         KeyedDataQueueEntry data = dq.read(key, 0, "EQ");
         while (data != null)
         {
            // Add queue entry to row data object.
            Object[] row = new Object[2];
            row[0] = new String(key);
            row[1] = new String(data.getData());
            rowData.addRow(row);

            // Get another entry from the queue.
            data = dq.read(key, 0, "EQ");
         }

         // Create an HTML converter object and convert the rowData to HTML.
         HTMLTableConverter conv = new HTMLTableConverter();
         conv.setUseMetaData(true);
         HTMLTable[] html = conv.convertToTables(rowData);

         // Display the output from the converter.
         System.out.println(html[0]);

HTML source generated from the Java source by the using HTMLTableConverter

Using the HTMLTableConverter class in the Java source example above generates the following HTML code.

<table>
<tr>
<th>Customer ID</th>
<th>Order Number</th>
</tr>
<tr>
<td>777-53-4444</td>
<td>12345-XYZ</td>
</tr>
<tr>
<td>777-53-4444</td>
<td>56789-ABC</td>
</tr>
</table>

How a browser displays the generated HTML

The following table shows how the HTML source code looks when viewed in a browser.

Customer ID Order Number
777-53-4444 12345-XYZ
777-53-4444 56789-ABC