import ws.*;

// Example of using WTable class on Passage Server

public class api_WTable
{
  public WTableList Request(WServer oServer, WParamList oParamList)
  { 
    int n;
    String  szField;
    WTableList oTableList, oTableListRun;
    WParamList oParamListRun;
    WTable     oTable, oTableRun;

    oTableList    = oServer.newTableList();
    oParamListRun = oServer.newParamList();
    oTable        = oServer.newTable();

    // There are two purposes of using WTable:
    // 1. To create table in this request and fill in with needed data
    // 2. To get table from running another request

    // 1. To create table in this request

    // Create a table
    oTable.addCol(50);   // column 0
    oTable.addCol(100);  // column 1
    oTable.addCol(10);   // column 2
    
    // Put data in a table
    oTable.addRow();     // row 0
    oTable.set(0,0,"aaa");
    oTable.set(0,1,"bbb");
    oTable.set(0,2,"ccc");

    oTable.addRow();     // row 1
    oTable.set(1,0,"111");
    oTable.set(1,1,"222");
    oTable.set(1,2,"333");

    n = oTable.getNRows();
    n = oTable.getNCols();
    szField = oTable.get(0,0);
    oTable.setRow(1);
    oTable.setColParam(0,"style='height:100px; background-color: #eeeeee';");
    oTable.setColParam(1,"style='height:100px; width:100px;'");

    oTableList.add(oTable); // table 0

    // 2. To get table from running another request

    oParamListRun.clear();
    oParamListRun.add("myparameter");
    oTableListRun = oServer.request("myrequest", oParamListRun);
    if (oTableListRun.getEC() != 0)
      return oTableListRun;

    oTableRun = oTableListRun.get(0); // Get table 0

    oTableList.add(oTableRun); // Add table 1

    return oTableList; 
  }
}