--Replacing standard insert method of NavigationTable
1 post
• Page 1 of 1
--Replacing standard insert method of NavigationTable
This article is outdated - please use our new system at
https://doc.sibvisions.com
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 presses 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:
- Code: Select all
rdbAddOns.eventAfterInserting().addListener(this, "doCancelInsert");
- Code: Select all
public void doCancelInsert() throws ModelException
{
rdbAddOns.restoreSelectedRow();
}
Don't insert new records.
Configure the NavigationTable:
- Code: Select all
navAddOns = new NavigationTable();
navAddOns.setDataBook(rdbAddOns);
navAddOns.setEditVisible(false);
navAddOns.eventInsert().addListener(this, "doNewAddOn");
- Code: Select all
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:
- Code: Select all
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...
-
Development@SIB - Posts: 325
- Joined: Mon Sep 28, 2009 1:54 pm
1 post
• Page 1 of 1