Hi guys,

For all those who have been asking for it, the SQL Table Model is now checked in the CVS. You can find it in the package net.sf.tapestry.contrib.table.model.sql. As I have mentioned before, the main feature is the delegation of sorting and paging to SQL using ORDER BY and LIMIT/OFFSET. This essentially means that a request is made every time you need to display a page, but you obtain only the data you need to display. Also, the data is not kept between requests, hence the load on the session state is minimal.

Here is some example code that uses the model (will be possible to be made even shorter soon):

public ITableModel getTableModel()
{
    ISqlConnectionSource objConnSrc = 
        new SimpleSqlConnectionSource("jdbc:postgresql://localhost/testdb", "testdb", "testdb");

    ISqlTableDataSource objDataSrc = 
        new SimpleSqlTableDataSource(objConnSrc, "test_table");

    SqlTableColumnModel objColumnModel = 
        new SqlTableColumnModel(new SqlTableColumn[] {
            new SqlTableColumn("language", "Language", true),
            new SqlTableColumn("country", "Country", true),
            new SqlTableColumn("variant", "Variant", true),
            new SqlTableColumn("intvalue", "Integer", true),
            new SqlTableColumn("floatvalue", "Float", true)
        });

    ITableModel objTableModel = new SqlTableModel(objDataSrc, objColumnModel);

    return objTableModel;
}

Please keep in mind that you will need Jakarta's commons-logging.jar to use the code (that will be a part of Tapestry's distribution from next release -- Howard has transitioned the codebase to it -- makes things easier).

If for some reason you cannot access the CVS and you need the code, just send me an email. If you have a problem, please send me an email as well so that I can fix it.

Finally, I have also started checking in improvements to the other parts of the Table component, many of which were requested here or in personal emails. I will make an announcement of what has been done in a few days when I finish.

Best regards,

-mb

 



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

Reply via email to