"Start change">
RecordListRowData example
The following example shows you how the RecordListRowData class
works:
// Create an AS/400 system object.
AS400 mySystem = new AS400 ("mySystem.myComp.com");
// Get the path name for the file.
QSYSObjectPathName file = new QSYSObjectPathName(myLibrary, myFile, "%first%", "mbr");
String ifspath = file.getPath();
// Create a file object that represents the file.
SequentialFile sf = new SequentialFile(mySystem, ifspath);
// Retrieve the record format from the file.
AS400FileRecordDescription recordDescription = new AS400FileRecordDescription(mySystem, ifspath);
RecordFormat recordFormat = recordDescription.retrieveRecordFormat()[0];
// Set the record format for the file.
sf.setRecordFormat(recordFormat);
// Get the records in the file.
Record[] records = sf.readAll();
// Create a RecordListRowData object and add the records.
RecordListRowData rowData = new RecordListRowData(recordFormat);
for (int i=0; i < records.length; i++)
{
rowData.addRow(records[i]);
}
// Create an HTML converter object and convert the rowData to HTML.
HTMLTableConverter conv = new HTMLTableConverter();
conv.setMaximumTableSize(3);
HTMLTable[] html = conv.convertToTables(rowData);
// Display the first HTML table generated by the converter.
System.out.println(html[0]);
The code example above generates the following HTML code through
the HTMLTableConverter:
<table>
<tr>
<th>CUSNUM</th>
<th>LSTNAM</th>
<th>INIT</th>
<th>STREET</th>
<th>CITY</th>
<th>STATE</th>
<th>ZIPCOD</th>
<th>CDTLMT</th>
<th>CHGCOD</th>
<th>BALDUE</th>
<th>CDTDUE</th>
</tr>
<tr>
<td>938472</td>
<td>Henning </td>
<td>G K</td>
<td>4859 Elm Ave </td>
<td>Dallas</td>
<td>TX</td>
<td align="right">75217</td>
<td align="right">5000</td>
<td align="right">3</td>
<td align="right">37.00</td>
<td align="right">0.00</td>
</tr>
<tr>
<td>839283</td>
<td>Jones </td>
<td>B D</td>
<td>21B NW 135 St</td>
<td>Clay </td>
<td>NY</td>
<td align="right">13041</td>
<td align="right">400</td>
<td align="right">1</td>
<td align="right">100.00</td>
<td align="right">0.00</td>
</tr>
<tr>
<td>392859</td>
<td>Vine </td>
<td>S S</td>
<td>PO Box 79 </td>
<td>Broton</td>
<td>VT</td>
<td align="right">5046</td>
<td align="right">700</td>
<td align="right">1</td>
<td align="right">439.00</td>
<td align="right">0.00</td>
</tr>
</table>
When you use this code in an HTML page, it looks like this:
CUSNUM |
LSTNAM |
INIT |
STREET |
CITY |
STATE |
ZIPCOD |
CDTLMT |
CHGCOD |
BALDUE |
CDTDUE |
938472 |
Henning |
G K |
4859 Elm Ave |
Dallas |
TX |
75217 |
5000 |
3 |
37.00 |
0.00 |
839283 |
Jones |
B D |
21B NW 135 St |
Clay |
NY |
13041 |
400 |
1 |
100.00 |
0.00 |
392859 |
Vine |
S S |
PO Box 79 |
Broton |
VT |
5046 |
700 |
1 |
439.00 |
0.00 |