Example: Presenting a resource list in a servlet

Use the ResourceListRowData class in conjunction with the HTMLFormConverter or HTMLTableConverter class to present a resource list in a servlet.

The columns for a ResourceListRowData object are specified as an array of column attribute IDs while each row represents a resource object.

   // Create the resource list.  This example creates 
   // a list of all messages in the current user's message
   // queue.
   AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD");
   RMessageQueue messageQueue = new RMessageQueue(system, RMessageQueue.CURRENT);

   // Create the ResourceListRowData object.  In this example,
   // there are four columns in the table.  The first column 
   // contains the icons and names for each message in the
   // message queue.  The remaining columns contain the text, 
   // severity, and type for each message.
   ResourceListRowData rowdata = new ResourceListRowData(messageQueue, 
       new Object[] { null, RQueuedMessage.MESSAGE_TEXT, RQueuedMessage.MESSAGE_SEVERITY,
                      RQueuedMessage.MESSAGE_TYPE } );

   // Create HTMLTable and HTMLTableConverter objects to
   // use for generating and customizing the HTML tables.
   HTMLTable table = new HTMLTable();
   table.setCellSpacing(6);
   table.setBorderWidth(8);

   HTMLTableConverter converter = new HTMLTableConverter();
   converter.setTable(table);
   converter.setUseMetaData(true);

   // Generate the HTML table.
   String[] html = converter.convert(rowdata);
   System.out.println(html[0]);