Hi guys,

I have completed SqlTableModel, which allows you to display the contents of a database table (or an SQL query in general) in a few lines using the table component. Here is a quick example off the top of my head:

public ITableModel getTableModel() {
  ISqlTableConnectionSource connSrc = new SimpleSqlTableConnectionSource("jdbc:odbc:database", "user", "pass");
  ISqlTableDataSource dataSrc = "new" SimpleSqlTableDataSource(connSrc, "recordsTable");
  SqlTableColumnModel columnModel = new SqlTableColumnModel(new String[] {
      "id", "ID",
      "name", "Name",
      ... etc.
    });
  
  return new SqlTableModel(dataSrc, columnModel);
}

and in the jwc/page you can just do:

<component id="table" type="contrib:Table">
  <binding name="tableModel" expression="tableModel"/>
</component>

That gives you pagination and sorting, all performed using SQL. The footprint of the data in the session is minimal, since only the state and columns are saved (the columns can be omitted as well, but a little bit more code is necessary).

 

At this point I can test the code with Postgres, InstantDB, McKoi, and Access (via ODBC). Can you guys help me with testing on Oracle, MySQL, DB2, SQL Server, or any other database that you have handy? The generated SQL is standard, so I do not anticipate problems, but you never know when DBs are concerned.

Please email me if you would like to help, I will respond within a day (have to take a break now :).

Thank you in advance,

-mb

 



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site

Reply via email to