Documentation

(applications)

Replacing standard insert method of NavigationTable

The NavigationTable has buttons for insert/update/delete and other standard functionality. You can replace standard functionality with your own methods, e.g.load a zip file and insert records parsed from the archive - instead of inserting a new, empty, record.

Here's an example screen (AddOns from VisionX):

If the user is pressing the + Button beside the table, an Open file dialog should appear, like this one:

After selecting a file, the file should be parsed and a new record with parsed information should be inserted in the table. The parsing will be done in a server-side method and the return value of the method will be inserted.

How is this possible?

First, configure the databook:

rdbAddOns.eventAfterInserting().addListener(this, "doCancelInsert");
 
public void doCancelInsert() throws ModelException
{
    rdbAddOns.restoreSelectedRow();
}

Don't insert new records.

Configure the NavigationTable:

navAddOns = new NavigationTable();
navAddOns.setDataBook(rdbAddOns);
navAddOns.setEditVisible(false);
navAddOns.eventInsert().addListener(this, "doNewAddOn");
 
public void doNewAddOn() throws Throwable
{
    getApplication().getLauncher().getFileHandle(this, "doInsertAddOn");
}
 
public void doInsertAddOn(IFileHandle pFileHandle) throws Throwable
{
    String sName = (String)getConnection().callAction("parseZip", pFileHandle);
 
    rdbAddOns.eventAfterInserting().setDispatchEventsEnabled(false);
 
    try
    {
        rdbAddOns.insert(false);
        rdbAddOns.setValue("NAME", sName);
    }
    finally
    {
        rdbAddOns.eventAfterInserting().setDispatchEventsEnabled(true);
    }
 
    rdbAddOns.saveSelectedRow();
}

It also would be possible to use a custom storage implementation and simply do a reload:

public void doInsertAddOn(IFileHandle pFileHandle) throws Throwable
{
    String sObjName = rdbAddOns.getName();
 
    getConnection().call(sObjName, "insertArchive", pFileHandle);
 
    rdbAddOns.reload();
}

The storage implementation could load all AddOns from the filesystem and not from the database.

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