This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Displaying Tables without a Database

Documents for the development of and with JVx.

--Displaying Tables without a Database

Postby Development@SIB » Thu Sep 16, 2010 9:59 am



This article is outdated - please use our new system at

https://doc.sibvisions.com




IDataBook is required as data container(Model) for the use of tables. In most cases RemoteDataBook is used to provide data from a database table. However, a table does not always exist in the database for which the data is displayed.

In this case MemDataBook can be used, which is an IDataBook implementation that works with data in the main memory. No server connection is necessary, and there is no communication between client and server.


Example

We want to create a table that displays all Java System Properties.

Code: Select all
MemDataBook mdbSystem = new MemDataBook();
mdbSystem.setName("SYSTEM");
         
IRowDefinition rowdef = mdbSystem.getRowDefinition();
rowdef.addColumnDefinition(new ColumnDefinition("KEY"));
rowdef.addColumnDefinition(new ColumnDefinition("VALUE"));
         
rowdef.getColumnDefinition("KEY").setLabel("Parameter");
rowdef.getColumnDefinition("VALUE").setLabel("Value");
         
mdbSystem.open();
         
try
{
    Properties props = System.getProperties();
            
    for (Map.Entry<Object, Object> entry : props.entrySet())
    {
        try
        {
            mdbSystem.insert(false);
            mdbSystem.setValue("KEY", entry.getKey());
            mdbSystem.setValue("VALUE", entry.getValue());
        }
        catch (SecurityException sec)
        {
            //nothing to be done
        }
    }
}
catch (SecurityException se)
{
    //read only allowed properties
    //...
    //...
}


MemDataBook has to be opened before it can be integrated. Before it is opened the desired columns should be defined, since by default there are no columns.

Columns are defined as follows:

Code: Select all
rowdef.addColumnDefinition(new ColumnDefinition("KEY"));

Each IDataBook has an IRowDefinition for the administration of the available columns. A column is defined using ColumnDefinition, which at a minimum contains the column name and data type (text, number, date, etc.).
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation